Repository navigation
errors: a missing argument says what's needed, and a typo suggests what was meant - #19
Merged
Merged
Conversation
…atches, a command tie says nothing
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8.
Errors from the CLI framework leaked through in its own voice (
ports free→accepts 1 arg(s), received 0), and typos got no help. Now every message is in ports' voice, says what's needed with an example to copy, and suggests the nearest real command or name when there's a clear one. Exit codes and stdout are unchanged everywhere. Suggestions go to stderr only, and--jsonstill prints[]on a miss.Real binary, main vs this branch:
ports freeaccepts 1 arg(s), received 0`ports free` needs a port — e.g. `ports free 3000`ports free 3000 8000accepts 1 arg(s), received 2`ports free` takes one port — got 2: 3000 8000ports completionaccepts 1 arg(s), received 0`ports completion` needs a shell — e.g. `ports completion zsh`ports completion badshellinvalid argument "badshell" for "ports completion"unknown shell "badshell" — bash, zsh, fish, or powershellports freesunknown command "frees" — run `ports --help`… — did you mean `ports free`?ports dctordid you mean `ports doctor`?ports find pyhtonnothing matching "pyhton"… — did you mean "python3.13"?ports kill shp… — try `ports find shp`… — did you mean "shop"?How suggestions work:
pyhtonfindspython3.13.l,h,find xandfind absuggest nothing; they're a few edits from almost anything.shpmeansshop, notshop-db.killonly suggests names it can actually match. A docker row'sdocker-proxyis never offered; its container and Compose service names are.kilbut notfrees,wiatordctor), so commands use the same edit distance.How it was verified
Gate, locally with CI's versions: unit ✓, build ✓, integration ✓ (uncached), installers ✓, gofmt ✓, vet ✓, lint ✓ (v2.13.2). Plus the real-binary table above, run against live listeners.
New tests in
cmd/suggest_test.go:TestEditDistance, including the swap and unicode cases.TestSuggestName: short and far queries, ties, the?placeholder, and kill's filter for docker-proxy, containers and Compose services.TestSuggestCommand, including a synthetic tie.TestArgsError: every message, plus a check that cobra's "arg(s)" wording never leaks.Risk
Tier: risky, because
cmd/root.goholds the exit-code mapping. No exit code or stdout output changes; only stderr text does, for argument-count errors, unknown commands, an unknown completion shell, andfind/killmisses.Rollback: revert the squash commit.
A fresh-context review blocked the first commit, rightly. It worked out whether an argument is required from the usage text, and
completion [bash|zsh|…]actually needs exactly one, soports completionstill showed cobra's wording. Now the command's own validator decides.Its should-fixes are also in:
killsuggested names it can't match;A re-review said ok to ship. Its two nits are the last commit: compare commands rather than spellings, so a name and its own alias can't tie, and fix a comment.
Notes for the release
Error messages say what's missing, with an example. Mistyped commands and names get a "did you mean" suggestion. Exit codes are unchanged.
Generated by Claude Code