Issue 9341: allow argparse subcommands to be grouped (original) (raw)

Issue9341

Created on 2010-07-23 12:17 by bethard, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
issue9341_1.patch paul.j3,2014-06-22 19:37 review
Messages (3)
msg111290 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2010-07-23 12:17
[Moved from http://code.google.com/p/argparse/issues/detail?id=53] It's currently not possible to have subcommands formatted in groups, e.g. instead of: 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 you should be able to get something like: subcommands: group1: a a subcommand help b b subcommand help c c subcommand help group2: d d subcommand help e e subcommand help
msg221297 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2014-06-22 19:37
This patch accomplishes this task by adding a _PseudoGroup class to _SubParsersAction. It's like the _ChoicesPseudoAction except that it maintains its own _choices_actions list. It takes advantage of the fact that formatter._format_actions is recursive when it comes to actions in _choices_actions. In fact it is possible to define groups within groups (not that I would recommend that). There is one simple test case in test_argparse, similar to the example in this issue.
msg223155 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2014-07-15 22:52
This patch probably won't work with [parents]. see http://bugs.python.org/issue16807
History
Date User Action Args
2022-04-11 14:57:04 admin set github: 53587
2014-07-15 22:52:41 paul.j3 set messages: +
2014-06-22 19:37:06 paul.j3 set files: + issue9341_1.patchkeywords: + patchmessages: +
2014-06-16 21:56:17 BreamoreBoy set nosy: + paul.j3versions: + Python 2.7, Python 3.5, - Python 3.2
2013-04-13 17:35:26 pconnell set nosy: + pconnell
2010-07-23 12:40:30 eric.araujo set nosy: + eric.araujoresolution: acceptedversions: + Python 3.2
2010-07-23 12:17:29 bethard create