Message216761
The idea of nesting a mutually_exclusive_group in a titled argument_group is already present in `test_argparse.py`.
class TestMutuallyExclusiveInGroup(MEMixin, TestCase):
def get_parser(self, required=None):
parser = ErrorRaisingArgumentParser(prog='PROG')
titled_group = parser.add_argument_group(
title='Titled group', description='Group description')
mutex_group = \
titled_group.add_mutually_exclusive_group(required=required)
mutex_group.add_argument('--bar', help='bar help')
mutex_group.add_argument('--baz', help='baz help')
return parser
failures = ['--bar X --baz Y', '--baz X --bar Y']
successes = [
('--bar X', NS(bar='X', baz=None)),
('--baz Y', NS(bar=None, baz='Y')),
]
successes_when_not_required = [
('', NS(bar=None, baz=None)),
]
usage_when_not_required = '''\
usage: PROG [-h] [--bar BAR | --baz BAZ]
'''
usage_when_required = '''\
usage: PROG [-h] (--bar BAR | --baz BAZ)
'''
help = '''\
optional arguments:
-h, --help show this help message and exit
Titled group:
Group description
--bar BAR bar help
--baz BAZ baz help
'''
So now the question is - do we to modify `add_mutually_exclusive_group` to streamline this task? An alternative is to add a note to the documentation, eg.
Note that currently mutually exclusive argument groups do not
support the title and description arguments of add_argument_group().
However a such a group can be added to a titled argument group.
(and then add an example) |
|
Date |
User |
Action |
Args |
2014-04-17 22:27:44 | paul.j3 | set | recipients:
+ paul.j3, bethard, r.david.murray, chris.jerdonek, tshepang, tati_alchueyr |
2014-04-17 22:27:44 | paul.j3 | set | messageid: <1397773664.74.0.304164674103.issue17218@psf.upfronthosting.co.za> |
2014-04-17 22:27:44 | paul.j3 | link | issue17218 messages |
2014-04-17 22:27:44 | paul.j3 | create | |
|