(registry-add built-registry command-map-spec)Adds or replaces a CommandMapSpec in a built registry. Identification is by the spec's :type key. If a spec with the same :type already exists it is replaced; otherwise the new spec is appended. Revalidates the registry.
Example: (-> (registry-create [...]) (registry-add my-cmd-spec))
Adds or replaces a CommandMapSpec in a built registry.
Identification is by the spec's :type key. If a spec with the same :type
already exists it is replaced; otherwise the new spec is appended.
Revalidates the registry.
Example:
(-> (registry-create [...])
(registry-add my-cmd-spec))(registry-create registry)Creates a 'Command' registry from a vector of CommandMapSpecs.
Accepts either:
Each command specification (CommandMapSpec) should be a map containing at least:
:type - a unique keyword identifying the command type:recognize-fn - a function to recognize the command in the instruction map
(fn [element] (and (map? element) (contains? element :your-command-key)):apply - a function to execute the command:
(fn [instruction command-map-obj command-data] ...):dependencies - declare way the command should build dependency
{:mode :all-inside} - all commands inside the current map are dependencies
{:mode :none} - no dependencies, the other commands may depend from it.
{:mode :point :point-key [:commando/from]} - special type of dependency
which declare that current command depends from the command it refer by
exampled :commando/from key.Additional optional keys can include:
:validate-params-fn - a function to validate command structures, and catch
invalid parameters at the analysis stage. Only if the function
return 'true' it meant that the command structure is valid.
(fn [data] (throw ...)) => Failure
(fn [data] {:reason "why"}) => Failure
(fn [data] nil ) => Failure
(fn [data] false ) => Failure
(fn [data] true ) => OKThe function returns a built registry that can be used to resolve Instruction
Example: (registry-create [commando.commands.builtin/command-from-spec commando.commands.builtin/command-fn-spec])
Creates a 'Command' registry from a vector of CommandMapSpecs.
Accepts either:
- A vector of CommandMapSpecs (order defines command scan priority)
- An already-built registry (returned as-is)
Each command specification (CommandMapSpec) should be a map containing at least:
- `:type` - a unique keyword identifying the command type
- `:recognize-fn` - a function to recognize the command in the instruction map
(fn [element] (and (map? element) (contains? element :your-command-key))
- `:apply` - a function to execute the command:
(fn [instruction command-map-obj command-data] ...)
- `:dependencies` - declare way the command should build dependency
{:mode :all-inside} - all commands inside the current map are dependencies
{:mode :none} - no dependencies, the other commands may depend from it.
{:mode :point :point-key [:commando/from]} - special type of dependency
which declare that current command depends from the command it refer by
exampled :commando/from key.
Additional optional keys can include:
- `:validate-params-fn` - a function to validate command structures, and catch
invalid parameters at the analysis stage. Only if the function
return 'true' it meant that the command structure is valid.
(fn [data] (throw ...)) => Failure
(fn [data] {:reason "why"}) => Failure
(fn [data] nil ) => Failure
(fn [data] false ) => Failure
(fn [data] true ) => OK
The function returns a built registry that can be used to resolve Instruction
Example:
(registry-create
[commando.commands.builtin/command-from-spec
commando.commands.builtin/command-fn-spec])(registry-remove built-registry command-map-spec-type)Removes a CommandMapSpec from a built registry by its :type. Revalidates the registry.
Example: (-> (registry-create [...]) (registry-remove :my/cmd))
Removes a CommandMapSpec from a built registry by its :type.
Revalidates the registry.
Example:
(-> (registry-create [...])
(registry-remove :my/cmd))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 |