I have a program that has many options available. For example, a configuration parameter for changing settings.
./app config -h
gives me help using regular argparse subcommands
now I would like to add another subcommand to the config subcommand called list to list config values
./app config list
in addition, this command must accept another option so that I can say
./app config list CATEGORY
only to display the configuration of one category
my code right now basically it's just with lots of 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 the subcommand in the subcommand. If possible, how? If not, is there any other way to achieve this?
Thanks at Advance
source share