Provides some options for a command line program.
Provides some options for a command line program.
(terminal {program-short-desc :short-desc
args :args
opts :options
cli-args :args-desc
execute :execute})
Executes program in terminal.
Runs fn in (:execute) with passed command line arguments (:args).
Supplies program with options (:opts). Supported default command line options are -h (--help) -t (--trace)
Wraps unhandled exceptions. If -t is set, returns full stack trace. Otherwise, returns only exception message.
Help provides short program description (:short-description), description of command line options, description of command line arguments, etc.
The format for description of command line arguments (:args-description) is: {:required [[argument-name1 argument-description1] [argument-name2 argument-description2] ...] :optional [[optional-argument-name1 argument-description1] [optional-argument-name2 argument-description2] ...]}
(require '[utilities.cmd :refer :all])
(def arguments
{:short-desc "Program short description goes here."
:args '(arg1 arg2 ... [optional-arg1] [optional-arg2] ...)
:opts '(["-o" "--option" "Set some option"
:id :opt])
:args-desc {:required
[["arg1" "Description for arg1 goes here."]
["arg2" "Description for arg2 goes here."]
...]
:optional
[["optional-arg1" "Description for optional-arg1 goes here."]
["optional-arg2" "Description for optional-arg2 goes here."]
...]}
:execute (fn[args](println "Hello, world!"))})
(terminal arguments)
Executes program in terminal. Runs fn in (:execute) with passed command line arguments (:args). Supplies program with options (:opts). Supported default command line options are -h (--help) -t (--trace) Wraps unhandled exceptions. If -t is set, returns full stack trace. Otherwise, returns only exception message. Help provides short program description (:short-description), description of command line options, description of command line arguments, etc. The format for description of command line arguments (:args-description) is: {:required [[argument-name1 argument-description1] [argument-name2 argument-description2] ...] :optional [[optional-argument-name1 argument-description1] [optional-argument-name2 argument-description2] ...]} ## Usage (require '[utilities.cmd :refer :all]) (def arguments {:short-desc "Program short description goes here." :args '(arg1 arg2 ... [optional-arg1] [optional-arg2] ...) :opts '(["-o" "--option" "Set some option" :id :opt]) :args-desc {:required [["arg1" "Description for arg1 goes here."] ["arg2" "Description for arg2 goes here."] ...] :optional [["optional-arg1" "Description for optional-arg1 goes here."] ["optional-arg2" "Description for optional-arg2 goes here."] ...]} :execute (fn[args](println "Hello, world!"))}) (terminal arguments)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close