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 the above script (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_TEST
Where 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_TEST
I’m at a lost on how to get the desired output and I would appreciate a friendly hand.