Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use a common mutually-exclusive-group as "root" of the two subgroups:</p> <pre class="lang-python prettyprint-override"><code>import argparse parser = argparse.ArgumentParser( description='this is the description', epilog="This is the epilog", argument_default=argparse.SUPPRESS ) parser.add_argument('-v', '--verbose', help='verbose', action='store_true', default=False) root_group = parser.add_mutually_exclusive_group() group_list = root_group.add_mutually_exclusive_group() group_list.add_argument('-m', help='list only modules', action='store_const', dest='list', const='modules', default='all') group_list.add_argument('-p', help='list only ports', action='store_const', dest='list', const='ports', default='all') group_list.add_argument('--list', help='list only module or ports', choices=['modules','ports'], metavar='&lt;modules/ports&gt;', default='all') group_simulate = root_group.add_mutually_exclusive_group() group_simulate.add_argument('-M', help='simulate module down', nargs=1, metavar='module_name', dest='simulate') group_simulate.add_argument('-P', help='simulate FC port down', nargs=1, metavar='fc_port_name', dest='simulate') group_simulate.add_argument('-I', help='simulate iSCSI port down', nargs=1, metavar='iSCSI_port_name', dest='simulate') group_simulate.add_argument('--simulate', help='simulate module or port down', nargs=1, dest='simulate') args = parser.parse_args() print args </code></pre> <p>Result:</p> <pre><code>$ python test.py -m -P asfafs usage: test.py [-h] [-v] [[-m | -p | --list &lt;modules/ports&gt;] [-M module_name | -P fc_port_name | -I iSCSI_port_name | --simulate SIMULATE] test.py: error: argument -P: not allowed with argument -m $ python test.py -m -p usage: test.py [-h] [-v] [[-m | -p | --list &lt;modules/ports&gt;] [-M module_name | -P fc_port_name | -I iSCSI_port_name | --simulate SIMULATE] test.py: error: argument -p: not allowed with argument -m </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload