diff --git a/bin/etherpump b/bin/etherpump index 0ec6d84..7e9c608 100755 --- a/bin/etherpump +++ b/bin/etherpump @@ -1,9 +1,26 @@ #!/usr/bin/env python3 +import os import sys +from pathlib import Path 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 = """ _ | | @@ -18,23 +35,15 @@ Usage: where CMD could be: - pull - index - dumpcsv - gettext - gethtml - creatediffhtml - list - listauthors - revisionscount - showmeta - html5tidy +{} For more information on each command try: etherpump CMD --help -""" +""".format( + subcommands() +) try: cmd = sys.argv[1]