How to Tell Which Subparser Was Used Argparser Python
If you take a look at the argparse documentation they suggest to use set_defaults on each of the parsers to associate a processing function depending on which parser is. This isnt quite right. Python Cli Apps The Easy And Better Way By Sahib Dhanjal Medium Myprogrampy -h --foo FOO optional arguments. . Earlier in the subclasses add_parser method the name and alias list. As mentioned before parser_name is used find the actual sub parser which is called with the remaining arg_strings. Pythons standard library module for interpreting command-line arguments argparse supplies a host of features making it easy to add argument handling to. I just realized if the subparser argument used defaultargparseSUPPRESS it would not clobber values default or user set by the main parser. Prog - usage information that will be displayed with sub-command help by default the name of the program and any positional arguments before the subparser a