(-parse-option {:keys [in update-fn arg-number schema] :as value-schema}
options
arg
argstail)Take the current arglist head arg, the tail args-tail. Depending on the value schema consume some items from the tail and when applicable pass them on toupdate-fn`. This is actually the core of
the work that transforms a vector of string to a map of options.
Take the current arglist head `arg`, the tail args-tail`. Depending on the value schema consume some items from the tail and when applicable pass them on to `update-fn`. This is actually the core of the work that transforms a vector of string to a map of options.
The malli transformer wrapping parse-args. To be used it with
m/decode, wrapped by mt/transformer. Merely turn a sequence of
arguments args into a map that (maybe) conforms to a schema. You
can compose this transformer to further refine command-line argument
parsing. See simple-cli-transformer for an example.
The malli transformer wrapping `parse-args`. To be used it with `m/decode`, wrapped by `mt/transformer`. Merely turn a sequence of arguments `args` into a map that (maybe) conforms to a `schema`. You can compose this transformer to further refine command-line argument parsing. See `simple-cli-transformer` for an example.
(break-long-option-and-value arg argstail)Expand an argument that contains both an option label and a value into two arguments: the label, and the value.
Expand an argument that contains both an option label and a value into two arguments: the label, and the value.
(break-short-option-group label+value-schemas arg argstail)Expand a group of short option labels into a several short labels and interpolate them with the tail of the arglist args-tail` depending on the number of arguments each option needs.
Expand a group of short option labels into a several short labels and interpolate them with the tail of the arglist args-tail` depending on the number of arguments each option needs.
(children-successor schema)Given a schema [:enum :a :b :c :d], return a Clojure map (that is,
a queryable data structure) that returns the next item of
:a -> :b -> :c -> :d <-> :d. The last item is mapped onto itself. If
the schema has a default value as a property, like in
[:enum {:default :b} :a :b :c :d] an additional mapping will be
made nil -> :c.
Primarily intended to be used on enum schema for non-idempotent options (like :verbose), but code is generic so you might think of a use case on another schema type.
Given a schema `[:enum :a :b :c :d]`, return a Clojure map (that is,
a queryable data structure) that returns the next item of
:a -> :b -> :c -> :d <-> :d. The last item is mapped onto itself. If
the schema has a default value as a property, like in
`[:enum {:default :b} :a :b :c :d]` an additional mapping will be
made nil -> :c.
Primarily intended to be used on enum schema for non-idempotent
options (like :verbose), but code is generic so you might think of a
use case on another schema type.Use it for straightforward, do-what-I-mean cli args parsing. Simple transformer for the most common use cases when you only want to get a (nested) map of options out of command-line arguments:
Use it for straightforward, do-what-I-mean cli args parsing. Simple transformer for the most common use cases when you only want to get a (nested) map of options out of command-line arguments: - Remove extraneous keys; - Inject values from environment variables; - Fills the blank with default values when applicable.
(label+value-schema {:keys [in schema] :as value-schema})Return MapEntry items, when applicable one for short, and long
option names.
Return `MapEntry` items, when applicable one for short, and long option names.
(name-items x)Take an argument and return a vector of items that will form an
option name. For example the option name for :a/b will be a-b.
Take an argument and return a vector of items that will form an option name. For example the option name for `:a/b` will be a-b.
(parse-args label+value-schemas args)Entry point to the technical work of turning a sequence of arguments
args into a map that (maybe) conforms to a schema. It returns a
map of the options as parsed according to the schema, but with two
additional keys:
::operands is a vector of application arguments, that is to say
command-line arguments that do not represent an option value.
::cli-args is the raw, untouched vector of command-line
arguments received as input. Perhaps you need it for some
additional validation of positional logic.
Entry point to the technical work of turning a sequence of arguments `args` into a map that (maybe) conforms to a `schema`. It returns a map of the options as parsed according to the schema, but with two additional keys: - `::operands` is a vector of application arguments, that is to say command-line arguments that do not represent an option value. - `::cli-args` is the raw, untouched vector of command-line arguments received as input. Perhaps you need it for some additional validation of positional logic.
(secret-transformer)(secret-transformer {:keys [secret-fn plaintext-fn]
:or {secret-fn (constantly "***") plaintext-fn nil}})A malli transformer that you can use to encode secret values into redacted strings or any other opaque type that can't be displayed in logs.
A malli transformer that you can use to encode secret values into redacted strings or any other opaque type that can't be displayed in logs.
(start-with? prefix path)Return true if the collection path starts with all the items of
collection prefix.
Return true if the collection `path` starts with all the items of collection `prefix`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |