paul j3 <[email protected]> added the comment:
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.
----------
Added file: https://bugs.python.org/file47574/issue22848.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue22848>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com