Liking cljdoc? Tell your friends :D

cli-matic.core


a-positional-parmclj

(a-positional-parm args option)

Reads one positional parameter from the arguments. Returns a vector [parm value] The value is NOT solved, so it's always a string.

Reads one positional parameter from the arguments.
Returns a vector [parm value]
The value is NOT solved, so it's always a string.
sourceraw docstring

all-subcommandsclj

(all-subcommands climatic-args)

Returns all subcommands, as strings. We get all versions of all subcommands.

Returns all subcommands, as strings.
We get all versions of all subcommands.
sourceraw docstring

all-subcommands-aliasesclj

(all-subcommands-aliases climatic-args)

Maps all subcommands and subcommand aliases to their canonical name. E.g. {'add': 'add', 'a': 'add'}.

We basically add them all, then remove nil keys.

Maps all subcommands and subcommand aliases
to their canonical name.
E.g. {'add': 'add', 'a': 'add'}.

We basically add them all, then remove
nil keys.

sourceraw docstring

arg-list-with-positional-entriesclj

(arg-list-with-positional-entries cfg cmd)

Creates the [arguments...]

Creates the `[arguments...]`
sourceraw docstring

assert-cfg-sanityclj

(assert-cfg-sanity currentCfg)

Checks configuration and throws if anything wrong.

  1. are :option values unique?
  2. are :short values unique?
  3. do we have any positional arguments in global config?

First we make a list of nil plus all subcmds.

Checks configuration and throws if anything wrong.

1. are :option values unique?
2. are :short values unique?
3. do we have any positional arguments in global config?

First we make a list of `nil` plus all subcmds.

sourceraw docstring

assert-unique-valuesclj

(assert-unique-values name vec-opts option)

Check that all values are unique. name is the area of the configuration vec-opts are the options to check option is the keyword to check.

Check that all values are unique.
name is the area of the configuration
vec-opts are the options to check
option is the keyword to check.
sourceraw docstring

assoc-new-multivalueclj

(assoc-new-multivalue parameter-map option v)

Associates a new multiple value to the current parameter map. If the current value is not a vector, creates a new vector with the new value.

Associates a new multiple value to the
current parameter map.
If the current value is not a vector, creates
a new vector with the new value.
sourceraw docstring

asStringclj

(asString s)

Turns a collection of strings into one string, or the string itself.

Turns a collection of strings into one string,
or the string itself.
sourceraw docstring

canonicalize-subcommandclj

(canonicalize-subcommand commands subcmd)

Returns the 'canonical' name of a subcommand, i.e. the one that appears in :command, even if we pass an alias or short version.

Returns the 'canonical' name of a subcommand,
i.e. the one that appears in :command, even
if we pass an alias or short version.
sourceraw docstring

capture-positional-parmsclj

(capture-positional-parms cfg subcmd remaining-args)

Captures positional parameters in the remaining-args of a subcommand.

Captures positional parameters in the remaining-args of
a subcommand.
sourceraw docstring

cm-opts->cli-optsclj

(cm-opts->cli-opts climatic-opts)

Out of a cli-matic arg list, generates a set of options for tools.cli. It also adds in the -? and --help options to trigger display of helpness.

Out of a cli-matic arg list, generates a set of
options for tools.cli.
It also adds in the -? and --help options
to trigger display of helpness.
sourceraw docstring

errors-for-missing-mandatory-argsclj

(errors-for-missing-mandatory-args climatic-options parsed-opts other-options)

Gets us a sequence of errors if mandatory options are missing. Options read by cli module are merged with other options, e.g. positional parameters.

Gets us a sequence of errors if mandatory options are missing.
Options read by cli module are merged with other options, e.g.
positional parameters.
sourceraw docstring

generate-a-commandclj

(generate-a-command {:keys [command short description]})

Maybe we should use a way to format commands

E.g. (pp/cl-format true "~{ ~vA ~vA ~vA ~}" v)

(clojure.pprint/cl-format true "~3a ~a" "pippo" "pluto")

Maybe we should use a way to format commands

E.g.
(pp/cl-format true "~{ ~vA  ~vA  ~vA ~}" v)


(clojure.pprint/cl-format true "~3a ~a" "pippo" "pluto")
sourceraw docstring

generate-global-command-listclj

(generate-global-command-list commands)

Creates a list of commands and descriptions. Commands are of kind ::S/commands

Creates a list of commands and descriptions.
Commands are of kind ::S/commands
sourceraw docstring

generate-global-helpclj

(generate-global-help cfg)

This is where we generate global help, so global attributes and subcommands.

This is where we generate global help, so
global attributes and subcommands.
sourceraw docstring

generate-sectionclj

(generate-section title lines)

Generates a section (as a collection of strings, possibly nested, but we'll flatten it out). If a section has no content, we return [].

Generates a section (as a collection of strings,
possibly nested, but we'll flatten it out).
If a section has no content, we return [].
sourceraw docstring

generate-sectionsclj

(generate-sections name version usage commands opts-title opts)

Generates all sections. All those positional parameters are not that nice.

Generates all sections.
All those positional parameters are not that nice.
sourceraw docstring

generate-subcmd-helpclj

(generate-subcmd-help cfg cmd)

This is where we generate help for a specific subcommand.

This is where we generate help for a specific subcommand.
sourceraw docstring

get-first-rest-description-rowsclj

(get-first-rest-description-rows row-or-rows)

get title and description of description rows

get title and description of description rows
sourceraw docstring

get-options-forclj

(get-options-for climatic-args subcmd)

Gets specific :options for a subcommand or, if nil, for global.

Gets specific :options for a subcommand or,
if nil, for global.
sourceraw docstring

get-options-summaryclj

(get-options-summary cfg subcmd)

To get the summary of options, we pass options to tools.cli parse-opts and an empty set of arguments. Parsing will fail but we get the :summary. We then split it into a collection of lines.

To get the summary of options, we pass options to
tools.cli parse-opts and an empty set of arguments.
Parsing will fail but we get the :summary.
We then split it into a collection of lines.
sourceraw docstring

get-subcommandclj

(get-subcommand climatic-args subcmd)

Given args and the canonical name of a subcommand, returns the map describing it.

Given args and the canonical name of a subcommand,
returns the map describing it.
sourceraw docstring

indentclj

(indent s)

Indents a single string, or each string in a collection of strings.

Indents a single string, or each string
in a collection of strings.
sourceraw docstring

indent-stringclj

(indent-string s)

Indents a single string.

Indents a single string.
sourceraw docstring

invoke-subcmdclj

(invoke-subcmd subcommand-def options)

Invokes a subcommand, and produces a Return Value.

The subcommand may:

  • return an integer (to specify exit code)
  • return nil
  • throw a Throwable object
Invokes a subcommand, and produces a Return Value.

The subcommand may:
 - return an integer (to specify exit code)
 - return nil
 - throw a Throwable object

sourceraw docstring

list-positional-parmsclj

(list-positional-parms cfg subcmd)

Extracts all positional parameters from the configuration.

Extracts all positional parameters from the configuration.
sourceraw docstring

mk-cli-optionclj

(mk-cli-option {:keys [option short as type default multiple env]
                :as cm-option})

Builds a tools.cli option out of our own format.

If for-parsing is true, the option will be used for parsing; if false, for generating help messages.

Builds a tools.cli option out of our own format.

If for-parsing is true, the option will be used for parsing;
if false, for generating help messages.

sourceraw docstring

mk-env-nameclj

(mk-env-name description env for-parsing?)

Writes a description with the env name by the end.

Writes a description with the env name by the end.
sourceraw docstring

mk-fake-argsclj

(mk-fake-args parms)

Builds the set of fake arguments that we append to our subcommands' own CLI items when we have positional parameters. If value is nil, option is not added.

We receive a map of options and output a vector of strings.

Builds the set of fake arguments that we append to our
subcommands' own CLI items
when we have positional parameters.
If value is nil, option is not added.

We receive a map of options and output a vector of strings.
sourceraw docstring

mkErrorclj

(mkError config subcommand error text)

Builds an error condition.

Builds an error condition.
sourceraw docstring

padclj

(pad s s1 len)

Pads s[, s1] to so many characters

Pads s[, s1] to so many characters
sourceraw docstring

parse-cmdsclj

(parse-cmds argv config)

This is where magic happens. We first parse global options, then stop, get the subcommand, parse specific options for the subcommand and if all went well we prepare run it.

This function returns a structure ::S/lineParseResult that contains information about what went wrong or the command to run.

This is where magic happens.
We first parse global options, then stop,
get the subcommand, parse specific options for the subcommand
and if all went well we prepare run it.

This function returns a structure ::S/lineParseResult
that contains information about what went wrong or the command
to run.
sourceraw docstring

parse-cmds-with-defaultsclj

(parse-cmds-with-defaults cmt-options argv in-order? fn-env)

Parses a command line with environemt defaults. We want environment defaults to be PARSED, so they will go through the same validation/check cycle as other elements. So - if any of them - we first run parsing disabling defaults, then go check if they are available in parsed elements; if they are not, we inject them as options to the left of argv and parse again. (as a side effect, if you have a wrong value for your option, and a default, the default will be used - YMMV).

Parses a command line with environemt defaults.
We want environment defaults to be PARSED, so they will go through
the same validation/check cycle as other elements.
So - if any of them - we first run parsing disabling defaults,
then go check if they are available in parsed elements;
if they are not, we inject them as options to the left of argv
and parse again.
(as a side effect, if you have a wrong value for your option, and a
default, the default will be used - YMMV).

sourceraw docstring

parse-cmds-with-positionsclj

(parse-cmds-with-positions config canonical-subcommand subcommand-parms)

To process positional parameters, first we run some parsing; if all goes well, we capture the values of positional arguments and run parsing again with a command line that has those items as if they were expressed.

This means that type casting and validation just happen in one place (CLI parsing) and we don't have to do them separately.

This function is used both for global and subcmd parsing, but when doing global parsing, positional parameters are not allowed, so they never come in.

To process positional parameters, first we run some parsing; if
all goes well, we capture the values of positional
arguments and run parsing again with a command line that has those
items as if they were expressed.

This means that type casting and validation just happen in one place
(CLI parsing) and  we don't have to do them separately.

This function is used both for global and subcmd parsing,
but when doing global parsing, positional parameters are
not allowed, so they never come in.
sourceraw docstring

parse-single-argclj

(parse-single-arg optionDef stringValue)

Parses and validates a single command. Returns its value, and an error message, in a vector [:keyword err val]. Parsing is OK if error message is nil.

Sequence is:

  • parsing (eg 2 -> 2), on exception parse error
  • validation via spec
  • validation via function, on exception validation error
Parses and validates a single command.
Returns its value, and an error message,
in a vector [:keyword err val].
Parsing is OK if error message is nil.

Sequence is:
- parsing (eg `2` -> 2), on exception parse error
- validation via spec
- validation via function, on exception validation error

sourceraw docstring

rewrite-optsclj

(rewrite-opts climatic-args subcmd)

Out of a cli-matic arg list, generates a set of options for tools.cli. It also adds in the -? and --help options to trigger display of helpness.

Out of a cli-matic arg list, generates a set of
options for tools.cli.
It also adds in the -? and --help options
to trigger display of helpness.
sourceraw docstring

run-cmdclj

(run-cmd args setup)

This is the actual function that is executed. It wraps run-cmd* and then does the printing of any errors, of help pages and System.exit. As it invokes Sys.exit you cannot use it from a REPL.

This is the actual function that is executed.
It wraps run-cmd* and then does the printing
of any errors, of help pages and  System.exit.
As it invokes Sys.exit you cannot use it from a REPL.
sourceraw docstring

run-cmd*clj

(run-cmd* setup args)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close