Message211205
Here's another possible solution: add a `help_groups` parameter to ArgumentParser. It is a list of base argument group names. `parser.add_argument(...)' places the action in one of those groups.
This is a generalization of the current code which creates two groups titled 'positional arguments' and 'optional arguments', and assigns actions based on 'optional strings' (e.g. '-f','--foo').
'help_groups' could have 1, 2, or 3 items.
1 - just one argument group
2 - the current postional/optional split, but with user chosen names
3 - a 'positional', 'required', and 'optional' split.
A 4 way split that distinguishes splits positionals between those that allow 0 values and 1 or more, is possible, but probably not that useful.
The changes are in the ArgumentParser.__init__ and _add_action methods.
'subparsers' do not inherit this parameter. I have not explored how it plays out with 'parents'. 'test_argparse.py' runs fine. |
|
Date |
User |
Action |
Args |
2014-02-14 07:32:12 | paul.j3 | set | recipients:
+ paul.j3, rhettinger, terry.reedy, bethard, eric.smith, eric.araujo, r.david.murray, docs@python, benschmaus, tshepang, martin.panter, mburger, Martin.d'Anjou |
2014-02-14 07:32:12 | paul.j3 | set | messageid: <1392363132.73.0.554537935133.issue9694@psf.upfronthosting.co.za> |
2014-02-14 07:32:12 | paul.j3 | link | issue9694 messages |
2014-02-14 07:32:12 | paul.j3 | create | |
|