This library defines a convenient way to parse command-line options.
The library exports a thin wrapper of SRFI-37: args-fold.
This macro wraps args-fold
provided by SRFI-37. It takes a list
of arguments, args, and scans it to find Unix-style command-line
options and binds their values to local variables according to bind-spec,
then executes body.
Following is the example how to use;
(define (usage args) ...)
(define (main args)
(with-args args
((verbose (#\v "verbose") #f #f)
(file (#\f "file") #t (usage args))
(debug-level (#\d "debug-level") #t "0")
. rest)
...))
The bind-spec must be one of the following forms;
(var (short long) value-required? default)
(var (short long) *
default)
var is variable name. short must be a character represents the short argument name. long must be a string represents the long argument name. value-required? specifies whether or not the optional argument has the value. default is the default form of the variable so it will be evaluated when the input args didn't have the specified option.
If the second form is used, the *
is syntactic keyword and the
passed value will be packed to list. Thus the script can take more than one
the same options.
If rest is not presented and args contains non listed argument,
then it raises an &assertion
. If it is, then it will pack the rest of
non listed argument as a list.