A simple subcommand parser for Clojure.
A simple subcommand parser for Clojure.
Max value of normalized levenshtein distance used in searching candidate commands. The default value is 0.5.
Max value of normalized levenshtein distance used in searching candidate commands. The default value is 0.5.
(candidate-message candidates)
Returns message for telling a user candidate commands. Returns nil if candidates is empty or nil.
Returns message for telling a user candidate commands. Returns nil if candidates is empty or nil.
(parse-cmds args option-specs command-specs & options)
Parses arguments sequence according to given option and subcommand specifications.
parse-cmds returns a map with seven entries:
{:options The options map, keyed by :id, mapped to the parsed value :command The keyword of the detected subcommand :arguments A vector of unprocessed arguments :options-summary A string containing a minimal options summary :commands-summary A string containing a minimal subcommands summary :errors A possible vector of error message strings generated during parsing; nil when no errors exist :candidates A vector of candidate commands}
A few function options may be specified to influence the behavior of parse-cmds:
:strict Parse required option arguments strictly: if a required argument value matches any other option, it is considered to be missing (and you have a parse error).
:options-summary-fn A function that receives the sequence of compiled option specs, and returns a custom option summary string.
:commands-summary-fn A function that receives the sequence of compiled command specs, and returns a custom command summary string.
Parses arguments sequence according to given option and subcommand specifications. parse-cmds returns a map with seven entries: {:options The options map, keyed by :id, mapped to the parsed value :command The keyword of the detected subcommand :arguments A vector of unprocessed arguments :options-summary A string containing a minimal options summary :commands-summary A string containing a minimal subcommands summary :errors A possible vector of error message strings generated during parsing; nil when no errors exist :candidates A vector of candidate commands} A few function options may be specified to influence the behavior of parse-cmds: :strict Parse required option arguments strictly: if a required argument value matches any other option, it is considered to be missing (and you have a parse error). :options-summary-fn A function that receives the sequence of compiled option specs, and returns a custom option summary string. :commands-summary-fn A function that receives the sequence of compiled command specs, and returns a custom command summary string.
(sub-command args & specs)
THIS IS A LEGACY FUNCTION and may be deprecated in the future. Please use clj-sub-command.core/parse-cmds in new applications.
THIS IS A LEGACY FUNCTION and may be deprecated in the future. Please use clj-sub-command.core/parse-cmds in new applications.
(summarize-cmds command-specs)
Reduces subcommands specs into a subcommands summary for printing at a terminal.
Reduces subcommands specs into a subcommands summary for printing at a terminal.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close