oh hi,

i needed (well, wanted) a command line parser more like opt parser in
ruby so i threw one together:

https://github.com/gar3thjon3s/clargon

thought i would share in case anyone else finds it useful. im aware of
with-command-line but it didnt quite do what i wanted as i needed
functions that parse things and i generally want the config as a map.

suggestions for improvements welcome.

cheers,
gaz

Example:

(clargon args
  (required ["-p" "--port" "the port for the server"] #(Integer. %)
  (optional ["--host" "hostname of server" :default "localhost"])
  (optional ["--verbose" "run in chatty mode" :default true])
  (optional ["--log-directory" "where you put logs" :default "/some/path"])))

with args of:

 '("-p" "8080" "--no-verbose" "--log-directory" "/tmp")

will produce a clojure map with the names picked out for you as keywords:

 {:port 8080
  :host "localhost"
  :verbose false
  :log-directory "/tmp"}

A flag of -h or --help is provided which will currently give a
documentation string:

Usage:

 Switches         Desc                     Default     Required
 --------         ----                     -------     --------
 -p, --port       the port for the server              Yes
 --host           hostname of server       localhost   No
 --verbose        run in chatty mode       true        No
 --log-directory  where you put logs       /some/path  No

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to