This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients Brett.Hannigan, Drake Bridgewater, barry, bethard, derks, floreal, mattlong, paul.j3, r.david.murray
Date 2018-05-07.03:03:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1525662220.63.0.682650639539.issue22848@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-05-07 03:03:40paul.j3setrecipients: + paul.j3, barry, bethard, r.david.murray, derks, mattlong, Brett.Hannigan, Drake Bridgewater, floreal
2018-05-07 03:03:40paul.j3setmessageid: <1525662220.63.0.682650639539.issue22848@psf.upfronthosting.co.za>
2018-05-07 03:03:40paul.j3linkissue22848 messages
2018-05-07 03:03:38paul.j3create