Cliopatra provides functionality to easily define and dispatch to multiple command-line utilities from single or multiple namespace entry points.
Some advantages of Cliopatra:
[org.clojars.runa/cliopatra "1.1.0"]
...
(:require [cliopatra.command :as command :refer [defcommand]])
...
(defcommand name-of-command
"documentation string for the command definition"
{;; usage-heading defaults to command's docstring if not provided
:usage-heading "documentation for command, prints above usage banner"
;; opts-spec = tools.cli opts spec + added required opts feature
;; The :required true option in the opt flags is a feature we've
;; layered ontop of tools.cli's option semantics to enable options that
;; are both named and required.
:opts-spec [["-f" "--foo" ... :required true]
["-b" "--bar"]]
;; bind-args-to is for positional non-option args. defaults to: args if
;; none is provided. In this case they will be bound to [baz quux].
:bind-args-to [baz quux]}
... body ...)
In the body of defcommand, some useful lexical bindings are made available:
(defcommand make-csv
"Create a file filled with come calculated data"
{:opts-spec [["--append" "Append to file?" :default true]]
:bind-args-to [output-file]}
(spit output-file (calculate-csv) :append append))
(defn -main [& args]
(command/dispatch 'my-lib.main args))
lein run make-csv my.csv --append true
Can you improve this documentation? These fine people already did:
Robert Levy, Alex Baranosky & Ram KrishnanEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close