-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Closed as not planned
Closed as not planned
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
import argparse
common_opts = argparse.ArgumentParser(add_help = False)
common_opts.add_argument("-F", "--foo")
common_opts.add_argument("-t", "--test")
specific_opts = argparse.ArgumentParser(
parents = [common_opts],
)
specific_opts.add_argument("-c", "--rfc")
specific_opts.add_argument("-f", "--foobar")
specific_opts.add_argument("-T", "--other-test")
specific_args = specific_opts.parse_args()If I execute argparse_parents.py -h I get:
usage: argparse_parents.py [-h] [-F FOO] [-t TEST] [-c RFC] [-f FOOBAR]
[-T OTHER_TEST]
options:
-h, --help show this help message and exit
-F, --foo FOO
-t, --test TEST
-c, --rfc RFC
-f, --foobar FOOBAR
-T, --other-test OTHER_TESTWhere I would like it to be:
usage: argparse-parents.py [-h] [-c RFC] [-f FOOBAR] [-F FOO] [-t TEST]
[-T OTHER_TEST]
options:
-h, --help show this help message and exit
-c, --rfc RFC
-f, --foobar FOOBAR
-F, --foo FOO
-t, --test TEST
-T, --other-test OTHER_TESTHow can I sort alphabetically the output of argparse's -h option by their POSIX options?
To me, this is a bug and a feature request at the same time as this question is two-folds:
-
Sorting upper case opts after lower case opts
-
Best/Recommended way to access the help usage
If you use
parentsyou have no control on the way the option are added and modifying the help output is the only way to have a coherent help output.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Projects
Status
Doc issues