(defcommand name doc-string specs & body)Defines a var with a function for use with cliopatra.command/delegate. Var has :cliopatra.command/command, :cliopatra.command/name, :cliopatra.command/usage, and :cliopatra.command/opts-spec metadata.
Usage:
(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
:opts-spec [["-f" "--foo" ... :required true]
["-b" "--bar"]]
;; bind-args-to is for positional non-option args. defaults to: args
:bind-args-to [baz quux]}
,,, body ,,,)
In the body of defcommand, these lexical bindings are made available:
usage (the usage heading and banner generated by tools.cli),
opts (a map of options and their values),
a lexical binding for each sym in bind-args-to (or args if unspecified),
and a lexical binding for each opt in opts-spec
Defines a var with a function for use with cliopatra.command/delegate.
Var has :cliopatra.command/command, :cliopatra.command/name,
:cliopatra.command/usage, and :cliopatra.command/opts-spec metadata.
Usage:
(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
:opts-spec [["-f" "--foo" ... :required true]
["-b" "--bar"]]
;; bind-args-to is for positional non-option args. defaults to: args
:bind-args-to [baz quux]}
,,, body ,,,)
In the body of defcommand, these lexical bindings are made available:
usage (the usage heading and banner generated by tools.cli),
opts (a map of options and their values),
a lexical binding for each sym in bind-args-to (or args if unspecified),
and a lexical binding for each opt in opts-spec(dispatch namespaces args & [env])Dispatch command-line args to a matching defcommand in any of the listed namespaces.
Usage:
(dispatch 'my-lib.main args) (dispatch ['my-lib.commands1 my-lib.commands2] args)
Dispatch command-line args to a matching defcommand in any of the listed namespaces. Usage: (dispatch 'my-lib.main args) (dispatch ['my-lib.commands1 my-lib.commands2] args)
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |