Message316249
I've attached a file that tries out the idea of building a custom `metavar` in the `add_parser` method.
It subclasses argparse._SubParsersAction, and registers it with the parser. No other modification to production code is required.
Subparsers with a blank `help`, appear in the choices, but not the helps.
Subparsers with a SUPPRESS don't appear in either, but can still appear in error messages
If everything is SUPPRESS, the metavar is '{}'. I have not tried to handle the case where the user provides his own 'metavar'. The regular class can handle that just fine.
There are too many untested edge cases to add this to production, but if anyone wants to try it, feedback will be welcomed.
This makes SUPPRESS in the subparser help behave more like SUPPRESS in the regular Action help. Otherwise a custom 'metavar' works just as well. |
|
Date |
User |
Action |
Args |
2018-05-07 03:03:40 | paul.j3 | set | recipients:
+ paul.j3, barry, bethard, r.david.murray, derks, mattlong, Brett.Hannigan, Drake Bridgewater, floreal |
2018-05-07 03:03:40 | paul.j3 | set | messageid: <1525662220.63.0.682650639539.issue22848@psf.upfronthosting.co.za> |
2018-05-07 03:03:40 | paul.j3 | link | issue22848 messages |
2018-05-07 03:03:38 | paul.j3 | create | |
|