;; with-command-line takes:
;; * args – the list of incoming args we want to process, such as from a main()
;; call
;; * desc – the usage description to print with –help
;; * cmdspec – a list of options and for each a help description and default value
;; * body – the body to execute in the context of the command-line values
;; Here's a simple example:
(defn -main [& args]
(with-command-line
args
"Usage: wc [-l|-w|-c] [-out out.txt] ..."
[[lines? l? "Count lines" false]
[words? w? "Count words" false]
[chars? c? "Count chars" false]
[out "The output file"]
files]
...implementation... ))
;; Here, lines?, words?, chars? specify boolean options. l?, w?, and c? are
;; alternate short forms for them. The string is a help description and the last
;; value is the default. out is a text option. file is a seq of additional
;; strings read at the end of the command-line.
;; All of the named cmdspec options (lines?, l?, out, etc) are given the value
;; specified by reading from the command-line, so you can see this kind of like
;; a let form.
;; with-command-line takes:
;; * args – the list of incoming args we want to process, such as from a main()
;; call
;; * desc – the usage description to print with –help
;; * cmdspec – a list of options and for each a help description and default value
;; * body – the body to execute in the context of the command-line values
;; Here's a simple example:
(defn -main [& args]
(with-command-line
args
"Usage: wc [-l|-w|-c] [-out out.txt] ..."
[[lines? l? "Count lines" false]
[words? w? "Count words" false]
[chars? c? "Count chars" false]
[out "The output file"]
files]
...implementation... ))
;; Here, lines?, words?, chars? specify boolean options. l?, w?, and c? are
;; alternate short forms for them. The string is a help description and the last
;; value is the default. out is a text option. file is a seq of additional
;; strings read at the end of the command-line.
;; All of the named cmdspec options (lines?, l?, out, etc) are given the value
;; specified by reading from the command-line, so you can see this kind of like
;; a let form.