Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions platform/spire/src/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ def configure(self, command: list, parser: argparse.ArgumentParser):
except AttributeError as e:
raise Exception("error configuring subcommand {!r}".format(subcommand)) from e

if 'help' not in self.mapping:
help_subparser = subparsers.add_parser(
'help',
description='print help about this command or a subcommnad',
help='show this help message and exit')
help_subparser.add_argument('subcommand', nargs='?')
def help_function(aargs):
if aargs.subcommand is None:
parser.print_help()
else:
try:
subparser = subparsers.choices[aargs.subcommand]
except KeyError:
print('{}: no such subcommand'.format(aargs.subcommand))
parser.print_help()
return
subparser.print_help()
help_subparser.set_defaults(argparse_invoke=help_function,
argparse_parser=help_subparser)

def short_doc(self):
return self.__doc__

Expand Down