I'm using the choices
argument in argparse.
If I run -h
I get the choices two times, once for -a
and once for --argument
. As I have around 30 options with long names the help text is quite cluttered. Can I only get it once? (without removing one of the flags).
Output from help:
$ python3 test.py -h
usage: test.py [-h] [-a {Option1,Option2}]
optional arguments:
-h, --help show this help message and exit
-a {Option1,Option2}, --argument {Option1,Option2}
Help.
Minimal example:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-a', '--argument', help='Help.', choices=['Option1', 'Option2'])
args = parser.parse_args()