I have a program that has many available options. For example a configuration option to change settings.
./app config -h
gives me the help using normal argparse subcommands
now i would like to add another subcommand to the config subcommand called list to list config values
./app config list
additionally that command should accept another option so that i could say
./app config list CATEGORY
only to list the config of one category
my code right now is basically this just with more commands
>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers(title='subcommands',
... description='valid subcommands',
... help='additional help')
>>> subparsers.add_parser('foo')
>>> subparsers.add_parser('bar')
>>> parser.parse_args(['-h'])
usage: [-h] {foo,bar} ...
optional arguments:
-h, --help show this help message and exit
subcommands:
valid subcommands
{foo,bar} additional help
So far I could not find any way to use a subcommand in a subcommand. If this is possible, how? If not, is there any other way to accomplish this goal?
Thanks in Advance
Seems to work.