diff options
| author | Stefan Boberg <[email protected]> | 2026-04-22 10:36:24 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-22 10:36:24 +0200 |
| commit | 213e53c4d603c51037f43c86b16fd90d2ac48c4a (patch) | |
| tree | 9bdc5374d5828a69cfd0a7b473c924461a97c2d8 /src/zencore/string.cpp | |
| parent | fix NamedEvent ftok() race on Linux/macOS (#1001) (diff) | |
| download | archived-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/zencore/string.cpp')
0 files changed, 0 insertions, 0 deletions