Add subcommand pretty listing
This commit is contained in:
parent
7677c7b250
commit
0f3edc0970
@ -1,9 +1,26 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from etherpump import __VERSION__
|
from etherpump import __VERSION__
|
||||||
|
|
||||||
|
|
||||||
|
def subcommands():
|
||||||
|
"""List all sub-commands for the `--help` output."""
|
||||||
|
subcommands = []
|
||||||
|
|
||||||
|
all_files = os.listdir(Path().absolute() / 'etherpump' / 'commands')
|
||||||
|
modules = filter(lambda file: not file.startswith('__'), all_files)
|
||||||
|
|
||||||
|
for module in modules:
|
||||||
|
name = module.split('.py')[0]
|
||||||
|
subcommands.append(f' {name}')
|
||||||
|
|
||||||
|
return '\n'.join(subcommands)
|
||||||
|
|
||||||
|
|
||||||
usage = """
|
usage = """
|
||||||
_
|
_
|
||||||
| |
|
| |
|
||||||
@ -18,23 +35,15 @@ Usage:
|
|||||||
|
|
||||||
where CMD could be:
|
where CMD could be:
|
||||||
|
|
||||||
pull
|
{}
|
||||||
index
|
|
||||||
dumpcsv
|
|
||||||
gettext
|
|
||||||
gethtml
|
|
||||||
creatediffhtml
|
|
||||||
list
|
|
||||||
listauthors
|
|
||||||
revisionscount
|
|
||||||
showmeta
|
|
||||||
html5tidy
|
|
||||||
|
|
||||||
For more information on each command try:
|
For more information on each command try:
|
||||||
|
|
||||||
etherpump CMD --help
|
etherpump CMD --help
|
||||||
|
|
||||||
"""
|
""".format(
|
||||||
|
subcommands()
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmd = sys.argv[1]
|
cmd = sys.argv[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user