aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/zenutil.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-22 10:36:24 +0200
committerGitHub Enterprise <[email protected]>2026-04-22 10:36:24 +0200
commit213e53c4d603c51037f43c86b16fd90d2ac48c4a (patch)
tree9bdc5374d5828a69cfd0a7b473c924461a97c2d8 /src/zenutil/zenutil.cpp
parentfix NamedEvent ftok() race on Linux/macOS (#1001) (diff)
downloadarchived-zen-213e53c4d603c51037f43c86b16fd90d2ac48c4a.tar.xz
archived-zen-213e53c4d603c51037f43c86b16fd90d2ac48c4a.zip
zen CLI: suggest similar commands on typos (#1000)
Surface "did you mean?" suggestions when the `zen` CLI is invoked with an unknown command or subcommand, so users don't have to dig through `zen --help` every time they mistype. ``` $ zen stauts Unknown command specified: 'stauts' The most similar commands are: status Run 'zen --help' for the full list of commands. ``` ``` $ zen cache statz Unknown subcommand: 'statz' The most similar subcommands are: stats ``` ## Algorithm - Damerau-Levenshtein edit distance with case-insensitive ASCII comparison — handles insertions, deletions, substitutions, and adjacent transpositions (e.g. `versoin` → `version`). - Small prefix-match bonus so short inputs like `ca` still surface longer commands like `cache` without having to relax the distance threshold to the point where it admits noise. - Distance threshold scales with input length (`clamp(len/2, 1, 3)`). Very short inputs rely on the prefix bonus; longer inputs tolerate up to three edits. - Top 5 results by distance, stable-sorted. - Hidden commands (deprecated shims like `cache-stats`) are excluded from the candidate set so we don't advertise them.
Diffstat (limited to 'src/zenutil/zenutil.cpp')
-rw-r--r--src/zenutil/zenutil.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/zenutil/zenutil.cpp b/src/zenutil/zenutil.cpp
index b9617b1ed..3c0fd9ab6 100644
--- a/src/zenutil/zenutil.cpp
+++ b/src/zenutil/zenutil.cpp
@@ -15,6 +15,7 @@
# include <zenutil/rpcrecording.h>
# include <zenutil/splitconsole/logstreamlistener.h>
# include <zenutil/process/subprocessmanager.h>
+# include <zenutil/suggest.h>
# include <zenutil/testartifactprovider.h>
# include <zenutil/wildcard.h>
@@ -34,6 +35,7 @@ zenutil_forcelinktests()
subprocessmanager_forcelink();
s3client_forcelink();
sigv4_forcelink();
+ suggest_forcelink();
testartifactprovider_forcelink();
wildcard_forcelink();
}