argparse: improve mutually exclusive groups

The current wording "Note that currently mutually exclusive argument
groups do not support the title and description arguments" implies
that in the future they will. However, that doesn't seem needed, as
one can simply wrap the mutually exclusive group into an argument with
with the desired title/description.
This commit is contained in:
Iustin Pop 2019-11-24 16:48:52 +01:00
parent 665ad3dfa9
commit 2e1470f441
1 changed files with 6 additions and 2 deletions

View File

@ -1915,9 +1915,13 @@ Mutual exclusion
usage: PROG [-h] (--foo | --bar) usage: PROG [-h] (--foo | --bar)
PROG: error: one of the arguments --foo --bar is required PROG: error: one of the arguments --foo --bar is required
Note that currently mutually exclusive argument groups do not support the Note that mutually exclusive argument groups do not support the
*title* and *description* arguments of *title* and *description* arguments of
:meth:`~ArgumentParser.add_argument_group`. :meth:`~ArgumentParser.add_argument_group`. If you want a mutually exclusive group
to be formatted separately, wrap it via an argument group:
>>> parser = argparse.ArgumentParser(prog='PROG')
>>> group = parser.add_argument_group('group').add_mutually_exclusive_group()
Parser defaults Parser defaults