How to handle CLI subcommands with argparse
问题 I need to implement a command line interface in which the program accepts subcommands. For example, if the program is called “foo”, the CLI would look like foo cmd1 <cmd1-options> foo cmd2 foo cmd3 <cmd3-options> cmd1 and cmd3 must be used with at least one of their options and the three cmd* arguments are always exclusive. I am trying to use subparsers in argparse, but with no success for the moment. The problem is with cmd2 , that has no arguments: if I try to add the subparser entry with