with-command-line-arguments is an ASDF-installable library providing an extensible macro for processing command line arguments. It includes a pretty --help output showing the current value of variables.
Email John Fremlin at MSI. His address is jf@[the domain without www].
View or edit the Cliki entry.
Start Lisp. Get asdf-install.
CL-USER> (asdf-install:install 'wclas)
CL-USER> (asdf:operate 'asdf:load-op 'wclas)
CL-USER> (defun main (&rest args)
(wclas:with-command-line-arguments (args :restvar remaining-arguments)
(tree-name
(pears :var-is-name t :name "p" :arguments (integer))
(apples :arguments (integer) :value 100)
(nil :name "pick" :description "pick the fruit from the tree" :arguments nil :func (lambda() (format t "PICKING!"))))
(values tree-name pears apples remaining-arguments)))
MAIN
CL-USER> (main "--pick" "--apples" "100")
PICKING!
NIL
NIL
100
NIL
CL-USER> (main "--pick" "--apples" "1" "--" "--apples" "10")
PICKING!
NIL
NIL
1
("--apples" "10")
CL-USER> (main "-tree-name" "oak" "-p" "6" "--help")
Command line syntax:
--eval: READ
Evaluate a Lisp expression and print the result
--help: no parameters
command line usage
--tree-name: STRING
tree-name (current value: "oak")
--pears --p: INTEGER
pears (current value: 6)
--apples: INTEGER
apples (current value: 100)
--pick: no parameters
pick the fruit from the tree
The command-line arguments received were: "-tree-name" "oak" "-p" "6" "--help"
"oak"
6
100
NIL
The API is documented.
git clone http://cl-www.msi.co.jp/projects/wclas/wclas.git