Open Freed-Wu opened 1 year ago
Hi, jap, have the same issue with the following configuration:
def get_arg_parser():
main_parser = argparse.ArgumentParser(prog=__appname__)
subparsers = main_parser.add_subparsers(dest="command", title='command')
parser = subparsers.add_parser("apply", add_help=True, help="apply platform definition to remote cloud provider")
parser.add_argument("--arg1", type=str, help="Help for argument 1")
parser.add_argument("arg2", type=str, help="Help for argument 2")
parser = subparsers.add_parser('destroy', add_help=True, help="destroy resources on cloud provider")
parser.add_argument("d_arg1", type=str, help="Help for d_argument 1")
parser.add_argument("d_arg2", type=str, help="Help for d_argument 2")
return main_parser
command: shtab --verbose --shell=zsh cli.cli.get_arg_parser
verbose output:
DEBUG:shtab.main:Namespace(parser='cli.cli.get_arg_parser', shell='zsh', prefix=None, preamble=None, prog=None, error_unimportable=False, loglevel=10) DEBUG:shtab:choices:_shtab_cli:['apply', 'destroy'] DEBUG:shtab:subcommand:apply DEBUG:shtab:subcommands:apply:{'cmd': 'apply', 'help': '', 'arguments': ['"(- : *)"{-h,--help}"[show this help message and exit]"', '"--arg1[Help for argument 1]:arg1:"', '":Help for argument 2:"'], 'paths': ['apply'], 'commands': {}} DEBUG:shtab:subcommand:destroy DEBUG:shtab:subcommands:destroy:{'cmd': 'destroy', 'help': '', 'arguments': ['"(- : *)"{-h,--help}"[show this help message and exit]"', '":Help for d_argument 1:"', '":Help for d_argument 2:"'], 'paths': ['destroy'], 'commands': {}} DEBUG:shtab:subcommands:_shtab_cli:['_shtab_cli', '_shtab_cli_apply', '_shtab_cli_destroy']
result:
_shtab_cli_commands() { local _commands=( "apply:" "destroy:" ) _describe 'pfm commands' _commands }
additionally, the positional arguments for the sub_parsers are also missing:
_shtab_cli_apply_options=( "(- : *)"{-h,--help}"[show this help message and exit]" "--arg1[Help for argument 1]:arg1:" ":Help for argument 2:" )
_shtab_cli_destroy_options=( "(- : *)"{-h,--help}"[show this help message and exit]" ":Help for d_argument 1:" ":Help for d_argument 2:" )
Resulting in strange behavior on the command line (shell is zsh)
Hi, I have the same behaviour. Any fix planned for that? Thanks! Paul
test:
should betest:test_help