zenlotus / argparse

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

Subcommands not printed in the same order they were added #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run 'python subcommands.py -h' (attached file)
2. Check the ordering of the subcommands in the output:
----
subcommands:
  {a,c,b,e,d}
    a          a subcommand help
    b          b subcommand help
    c          c subcommand help
    d          d subcommand help
    e          e subcommand help
----

The ordering between brackets is different than the ordering in the one-line 
help for each command below. This could be a little confusing to the user.

What is the expected output? What do you see instead?
The expected output would be to use the same ordering in both places. In 
particular the same ordering that was used in the code when using the 
_SubParsersAction.add_parser method:
----
subcommands:
  {a,b,c,d,e}
    a          a subcommand help
    b          b subcommand help
    c          c subcommand help
    d          d subcommand help
    e          e subcommand help
----

What version of the product are you using? On what operating system?
OS: Ubuntu
Version: source code (rev. 87)
Python: 2.6.5

Please provide any additional information below.
Please have a look at the attached diff. It contains a patch that worked for me 
to preserve the ordering used in the code.

To make that possible it uses action._choices_actions (a list) instead of 
action.choices (a dictionary).

Original issue reported on code.google.com by javier.c...@gmail.com on 18 Jun 2010 at 9:00

Attachments:

GoogleCodeExporter commented 9 years ago
This issue is probably present also in the python 2.7 sources in which the 
argparse library has been added. Should I report this in the python issue 
tracker as well?

Original comment by javier.c...@gmail.com on 18 Jun 2010 at 9:10

GoogleCodeExporter commented 9 years ago
Yes, please report this to the Python issue tracker (for both Python 2.7 and 
3.2). I plan to close down the Google code tracker, I just haven't had the time 
yet.

Original comment by steven.b...@gmail.com on 18 Jun 2010 at 10:13

GoogleCodeExporter commented 9 years ago
Done:
http://bugs.python.org/issue9026

Original comment by javier.c...@gmail.com on 18 Jun 2010 at 10:27

GoogleCodeExporter commented 9 years ago
Moved to bugs.python.org.

Original comment by steven.b...@gmail.com on 23 Jul 2010 at 2:19