Command line parameter parsing

Aug 16, 2008
124
0
#1
Does Take Command have something similar to Python's optparse/argparse module or to GNU's getopt or Linux shell's getopts command or would I have to completely script option handling myself?

How would I start doing this? Has anyone ever done it?

I would like to mimic the following script output I have in Python:

> script.py --help
usage: script.py [-h] [-v]

script.py does something

Special options:
-h, --help show this help message and exit
-v, --version show program's version number and exit

> script.py -v
script.py 1.0

> script.py -f
usage: script.py [-d] [-h] [-v]
script.py: error: unrecognized arguments: -f
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,588
46
Albuquerque, NM
prospero.unm.edu
#2
Does Take Command have something similar to Python's optparse/argparse module or to GNU's getopt or Linux shell's getopts command or would I have to completely script option handling myself?
NthArgument() might be what you're looking for. (I haven't used it myself; being basically dumb, I wrote my own arg parser, and tweak it to fit the needs of each plugin.)