rill/cli
模块 Small data-driven command parser. Spec keys: :name, :summary, · 12 个符号
:options, :commands (string-key map), :command-order, :positionals. Option {:name "quota" :key :quota :short "q" :type :integer
:required true :default 100 :min 0 :choices [...] :help "..."}.
Global options compose with selected command options; command options override declarations with the same name. Repeated flags are rejected. Supports --name value, --name=value, -short, --, -h/--help; no implicit abbreviations, permissive unknown flags or parser dependency.
概览
rill--has
(defn rill--has [m key] …)
(rill--has m key) — true when map m contains key, without relying on a contains? primitive.
rill--options
(defn rill--options [root selected] …)
(rill--options root selected) — merges the spec's global options with the selected command's options; command options with the same :name override global ones.
rill--option
(defn rill--option [options flag] …)
(rill--option options flag) — looks up an option by --long or -short form; errors on unknown or ambiguous flags.
rill--value
(defn rill--value [option raw] …)
(rill--value option raw) — coerces a raw argv string per the option's :type (:flag, :string, :integer), enforces :min/:max for integers and :choices for any type. Errors with invalid-input messages on coercion or range failures.
rill-parse
(defn rill-parse [spec argv] …)
(rill-parse spec argv) — parses argv against a spec; returns {:command :options :args :help :spec :command-spec}. Supports --name value, --name=value, -short, --, -h/--help. Applies option :default values, enforces :required options, rejects repeated flags and unexpected positionals. Errors carry an "invalid-input: " prefix.
rill--join
(defn rill--join [separator parts] …)
(rill--join separator parts) — variadic str-join over a collection of parts.
rill-help
(defn rill-help [spec command] …)
(rill-help spec command) — renders a usage string for spec, or for one command when given. Lists commands in :command-order (falls back to map key order, which is undefined) and all options. Errors on an unknown command name.
rill-dispatch
(defn rill-dispatch [parsed handlers] …)
(rill-dispatch parsed handlers) — if parsed help, returns rill-help text; otherwise calls the handler for parsed :command with the full parsed map. Errors when no handler is registered.
rill-run
(defn rill-run [spec handlers] …)
(rill-run spec handlers) — parses (host/argv) against spec and dispatches to handlers. Requires the host argv binding.
rill-grove-options
(def rill-grove-options …)
Real Grove command requirements, independent of its implementation. Publication has no --force/auto-approve switch. Unknown flags fail closed. rill-grove-options — vector of Grove CLI option declarations shared by all Grove commands; real Grove command requirements, independent of the Grove implementation. :case, :quota, :workers, :expected-version, :max-turns carry types/limits. Publication has no --force/auto-approve switch; unknown flags fail closed.
rill--required
(defn rill--required [names] …)
(rill--required names) — copies the named rill-grove-options entries, each marked :required true, as a command's option list.
rill-grove-spec
(def rill-grove-spec …)
rill-grove-spec — the Grove CLI parse spec: 11 commands (demo…serve), global options above, per-command required options, and a fixed :command-order for help rendering.