Message387278
Hey.
AFAIU, the sole purpose of ArgumentParser.add_argument_group() is for the grouping within the help output.
It would be nice, if one could create a mutually exclusive group (with ArgumentParser.add_mutually_exclusive_group) from/within such a "normal" group, so that the mutually exclusive arguments are listed within the group, but are still, mutually exclusive.
Right now when doing something like:
parser = argparse.ArgumentParser()
parser_group = parser.add_argument_group("INPUT OPTIONS")
parser_group_mutually_exclusive = parser_group.add_mutually_exclusive_group(required=False)
parser_group_mutually_exclusive.add_argument("--from-args")
parser_group_mutually_exclusive.add_argument("--from-files")
parser_group_mutually_exclusive.add_argument("--from-stdin")
parser_group.add_argument("-0", help="null delimited pathnames")
it works, but the mutually exclusive options are note printed within the "INPUT OPTIONS", but rather at the normal "optional arguments:" section of the help.
The above example also kinda shows what this could be used for:
- one might have e.g. a group for input options, and amongst that the mutually exclusive "--from-*" which specify the source of the input.
Cheers,
Chris. |
|
Date |
User |
Action |
Args |
2021-02-19 02:28:41 | calestyo | set | recipients:
+ calestyo |
2021-02-19 02:28:41 | calestyo | set | messageid: <1613701721.93.0.742004676065.issue43259@roundup.psfhosted.org> |
2021-02-19 02:28:41 | calestyo | link | issue43259 messages |
2021-02-19 02:28:41 | calestyo | create | |
|