(defcmd name docstring? [params*] body)
Like defn, but the resulting function can be invoked from the command line The docstring? and the arguments metadata are used to generate the CLI options.
Example: (defcmd say-hello "Say Hello command" [name & [^{:short "-l" :enum ["en" "es"] :default "en"} lang]] ;; do something with name and lang )
The required arguments are converted to positional command arguments. A vector of optional arguments can be specified, and will be converted to optional command arguments.
The following metadata can be used with required and optional arguments: :doc Argument documentation :validate A tuple like [validate-fn validate-msg] to validate the passed argument value :enum A vector of allowed values :parse-fn A function to convert the option value string to the desired type
The optional arguments additionally support the following metadata: :short The short option prefix, e.g "-o" :long? Allow long name option. Defaults to true. Long name is generated from the argument name. :default The default value. :default-fn A function invoke to get the default value
Like defn, but the resulting function can be invoked from the command line The docstring? and the arguments metadata are used to generate the CLI options. Example: (defcmd say-hello "Say Hello command" [name & [^{:short "-l" :enum ["en" "es"] :default "en"} lang]] ;; do something with name and lang ) The required arguments are converted to positional command arguments. A vector of optional arguments can be specified, and will be converted to optional command arguments. The following metadata can be used with required and optional arguments: :doc Argument documentation :validate A tuple like [validate-fn validate-msg] to validate the passed argument value :enum A vector of allowed values :parse-fn A function to convert the option value string to the desired type The optional arguments additionally support the following metadata: :short The short option prefix, e.g "-o" :long? Allow long name option. Defaults to true. Long name is generated from the argument name. :default The default value. :default-fn A function invoke to get the default value
(defopt name docstring? [options*])
Declares a global variable that's exposed as a command line option. The docstring? and the options are used to generate the CLI options. Example: (defopt verbose "Verbosity Level" :long? false :short "-v" :update-fn inc)
The following options are allowed, and have the semantics as the corresponding options in Clojure tools.cli :short The short option prefix, e.g "-o" :long? Allow long name option. Defaults to true. Long name is generated from the argument name. :default The default value. :default-fn A function invoke to get the default value :validate A tuple like [validate-fn validate-msg] to validate the passed option value :enum A vector of allowed values :parse-fn A function to convert the option value string to the desired type
Declares a global variable that's exposed as a command line option. The docstring? and the options are used to generate the CLI options. Example: (defopt verbose "Verbosity Level" :long? false :short "-v" :update-fn inc) The following options are allowed, and have the semantics as the corresponding options in Clojure tools.cli :short The short option prefix, e.g "-o" :long? Allow long name option. Defaults to true. Long name is generated from the argument name. :default The default value. :default-fn A function invoke to get the default value :validate A tuple like [validate-fn validate-msg] to validate the passed option value :enum A vector of allowed values :parse-fn A function to convert the option value string to the desired type
(exec! main-class-ns arguments)
Parses the arguments and executes the specified command
Parses the arguments and executes the specified command
(exit status msg)
Prints msg
and exist with the given status
Prints `msg` and exist with the given `status`
(exit-on-error action message)
(exit-on-error action message-fn)
Tries to execute the action, if successful returns action result, otherwise prints the given message to std error
Tries to execute the action, if successful returns action result, otherwise prints the given message to std error
(prompt message [options*])
Prompts for user input. The following options are supported: :password? If true, it will hide the user input
Prompts for user input. The following options are supported: :password? If true, it will hide the user input
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close