I’m using the argh library to create a python command line tool. Several of the names I’m using have turned out to be pretty long, e.g.:
./my_program.py download-and-parse-data --randomize-order --training-percent 80
Is there a simple way to allow abbreviations? For example, here’s a potential abbreviated version of the above line.
./my_program.py dpd -r -t 80
Ideally, I’d like to be able to use both command-line forms — the long, informative version, as well as the short, easy-to-type version. Is there a good way to do this?
You can do this quite easily with
argparse‘sadd_subparsers()method. See the docs here.In your case It might break down to this:
EDIT
In each
add_argument()call you can also use multiple argument names. See docs here. E.g: