paul j3 added the comment:
This patch adds a MultiGroupHelpFormatter that formats groups even if they
share actions or the actions are not in the same order as in the parse._actions
list. It sorts the groups so positional actions, if any appear in the correct
order.
A long test case generates this help:
usage: PROG [-h] [-a A | -c C] [-a A | -d D] [-a A | -b B] [-b B | -d D]
[-d D | x] foo [-b B | y]
positional arguments:
x x help
foo foo help
y y help
optional arguments:
-h, --help show this help message and exit
-a A a help
-b B b help
-c C c help
-d D d help
In the 2nd usage line, the 2 groups, and action foo, are shown in the order in
which x, foo, y were defined (and hence will be parsed), even though the groups
were not defined in that order.
The default formatter could not format these groups, generating '[-h] [-a A]
[-b B] ... x foo y' instead.
I have included the latest patch from http://bugs.python.org/issue11874. This
splits the usage line generated by _format_actions_usage into parts that are
groups or independent actions. The goal there is to correctly split long usage
lines into multiple lines. Here it makes it easier to format groups and
actions in new order.
If existing actions are added to new group as in the original patch for this
issue, that group gets a no_usage = True attribute. The default formatter then
will not attempt to format this group. The MultiGroupHelpFormatter ignores this
attribute.
This patch needs better documentation. Test cases also need refinement,
improving the names, and eliminating redundancies. Some of the new tests are
copies of existing ones, but using the new formatter.
----------
Added file: http://bugs.python.org/file30921/multigroup_1.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue10984>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com