Pure helpers for actionable Hive error/help messages.
Pure helpers for actionable Hive error/help messages.
(command-message {:keys [tool command valid-commands examples hint]})Message for invalid command/tool dispatch.
Commands are rendered with label, so a namespaced vocabulary keeps its
namespaces in the list.
Message for invalid command/tool dispatch. Commands are rendered with `label`, so a namespaced vocabulary keeps its namespaces in the list.
(expected-message {:keys [param expected actual actual-type hint example wrong
right]})Build an Elm-style expectation message.
Build an Elm-style expectation message.
(label x)How a command, a param or a choice is SHOWN and MATCHED.
A qualified keyword keeps its namespace: :timeline/insert-clip is
"timeline/insert-clip", not "insert-clip". name alone drops it, which
for a namespaced vocabulary turns a list of choices into nonsense
(:project/info and :media/list both becoming bare info and list)
and makes the edit-distance suggestions compare the wrong strings.
Everything else is unchanged: an unqualified keyword, a symbol and a string all render exactly as they did.
How a command, a param or a choice is SHOWN and MATCHED. A qualified keyword keeps its namespace: `:timeline/insert-clip` is "timeline/insert-clip", not "insert-clip". `name` alone drops it, which for a namespaced vocabulary turns a list of choices into nonsense (`:project/info` and `:media/list` both becoming bare `info` and `list`) and makes the edit-distance suggestions compare the wrong strings. Everything else is unchanged: an unqualified keyword, a symbol and a string all render exactly as they did.
(levenshtein-distance a b)Dependency-free edit distance for command suggestions.
Dependency-free edit distance for command suggestions.
(suggest input choices)(suggest input choices limit)The limit closest choices to input by edit distance.
Distance is measured over label, so a namespaced vocabulary compares
"timeline/insert-clip" rather than "insert-clip". Measuring bare names
makes every route in one namespace look equally close to every route in
another, which is how a suggestion list ends up offering start, abort
and opacity for a mistyped timeline/insert-clips.
The `limit` closest choices to `input` by edit distance. Distance is measured over `label`, so a namespaced vocabulary compares "timeline/insert-clip" rather than "insert-clip". Measuring bare names makes every route in one namespace look equally close to every route in another, which is how a suggestion list ends up offering `start`, `abort` and `opacity` for a mistyped `timeline/insert-clips`.
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 |