lib.Cmd: Add description property
Add keyword-argument description to Cmd.__init__(), and default it to help. Also, add a property .description returning it, and add it to add_parser() so that it shows up in the usage message.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
f4d0828713
commit
cc6febcda3
2 changed files with 12 additions and 2 deletions
|
|
@ -27,7 +27,12 @@ class App: # export
|
|||
def __init__(self, description: str = '', name_filter: str = '^Cmd.*', modules: None=None, eloop: None=None) -> None:
|
||||
|
||||
def add_cmd_to_parser(cmd, parsers):
|
||||
parser = parsers.add_parser(cmd.name, help=cmd.help, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser = parsers.add_parser(
|
||||
cmd.name,
|
||||
help = cmd.help,
|
||||
description = cmd.description,
|
||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
parser.set_defaults(func=cmd.run)
|
||||
cmd.add_arguments(parser)
|
||||
cmd.set_parser(parser)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue