Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 87 by
myselfas...@gmail.com: Serious issues with nested mutex
groups in help output
http://code.google.com/p/argparse/issues/detail?id=87
The following is the code from lines 392 to 409 of the argparse.py code,
where the parentheticals and brackets are being built-up.
==============================================
end = start + len(group._group_actions)
if actions[start:end] == group._group_actions:
for action in group._group_actions:
group_actions.add(action)
if not group.required:
if start in inserts:
inserts[start] += ' ['
else:
inserts[start] = '['
inserts[end] = ']'
else:
if start in inserts:
inserts[start] += ' ('
else:
inserts[start] = '('
inserts[end] = ')'
for i in range(start + 1, end):
inserts[i] = '|'
==============================================
Problem 1: When a nested mutex group is the right-most option of another
mutex group, the right brackets are not right:
usage: GDriveFS Tool [-h] [-u | -a authcode | [-b | -c authcode2]
Problem 2: When a nested mutex group is the left-most option of another
mutex group, there is a missing bar to the right of that nested group, in
the parent.
usage: GDriveFS Tool [-h] [[-b | -c authcode2] -u | -a authcode]
Problem 3: You can fix problem (1) by doing (a), but then there is an extra
bar inside the child mutex on the right, when that child mutex is the
left-most option (b):
a)
Change:
inserts[end] = ']'
To:
if end in inserts:
inserts[end] += '] '
else:
inserts[end] = ']'
b)
usage: GDriveFS Tool [-h] [[-b | -c authcode2 |] -u | -a authcode]
In all likelihood, this will all have to be reflowed due to a flawed (and
difficult-to-decypher) design.
I know it's obnoxious for some uninvited outsider to point out a serious
problem without presenting a solution. I'll work on a potential solution
for you guys if I have time.