zenlotus / argparse

Automatically exported from code.google.com/p/argparse
Other
0 stars 0 forks source link

Serious issues with nested mutex groups in help output #87

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by myselfasunder@gmail.com on 14 Sep 2012 at 4:21

GoogleCodeExporter commented 9 years ago
This is in version 1.1, by the way.

Original comment by myselfasunder@gmail.com on 14 Sep 2012 at 4:22

GoogleCodeExporter commented 9 years ago
The argparse module is not developed here. Please file issues at 
bugs.python.org.

Original comment by steven.b...@gmail.com on 14 Sep 2012 at 8:24