unixscripts:2-argp.sh
This is an old revision of the document!
argp.sh(1) is a wrapper around getopt(1) to make life much easier for script developers. It's used in most of my scripts - look at them for examples of use. There's just one essential file to install - the script itself. Put it somewhere on your path, typically in /usr/local/bin
:
To use argp.sh(1) a script pipes in a description of its options and the script generates the code for getopt(1) - as a plus it also provides automatic help and man page production.
It buys you:
- all the goodness of getopt(1)
- define options in one central place together with descriptions.
- fewer 'magic' and duplicated values in your code
- better consistency between the getopt(1) calling parameters, the case statement processing the user's options and the help/man pages
- less spaghetti in your own code
- much, much easier to maintain
- automatic help-page and man-page printing using the same data sources
- checking of option consistency at runtime
- range checking of option values at runtime
- pretty easy to use (just copy and paste from one of my example scripts)
- portable to OS's without long option support - the help page adapts too
Note that argp.sh(1) deprecates an older script that I wrote called process-getopt(1).
There is also a 'c' version of argp.sh(1) in case you need speed.
- Homepage, Releases and Repository: Sourceforge
To get the latest:
svn checkout svn://svn.code.sf.net/p/argpsh/code/trunk argpsh-code
unixscripts/2-argp.sh.1450173018.txt.gz · Last modified: 2015/12/15 02:50 by admin