Core implementation
Core implementation
(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 arguments metadata supports the following attributes: :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
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 arguments metadata supports the following attributes: :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
(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