Repository navigation
Unify wt step <typo> errors with clap-native format - #2215
Merged
Merged
Conversation
Mirror the top-level `wt <typo>` format for unrecognized step
subcommands. The custom `bail!` paths in `step_alias` are replaced by
a synthesized `clap::Error{InvalidSubcommand}` routed through
`enhance_and_exit_error` — same `tip:`/`Usage:` rendering, exit code 2.
User-configured aliases are fed into `SuggestedSubcommand`, so a typo
like `wt step deplyo` still suggests `deploy` when it is a user alias.
The full alias list lives in `wt step --help` (already augmented by
`augment_step_help`); the error just points there via
`Usage: wt step <COMMAND>` and the standard `--help` hint.
Co-Authored-By: Claude <[email protected]>
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.
Follow-up to #2212. That PR restored clap-native errors for top-level
wt <typo>; this one applies the same treatment one level down sowt step <typo>reads identically.The three custom
bail!branches instep_alias(Unknown step command X — perhaps Y?,Unknown step command X (no aliases configured),Unknown alias X (available: …)) are replaced by a synthesizedclap::Error{InvalidSubcommand}routed throughenhance_and_exit_error. Output now reads:Exit code is 2 (clap convention) instead of 1.
User-configured aliases are fed into
SuggestedSubcommand, so a typo likewt step deplyostill suggestsdeploywhendeployis a user alias —wt step usuggestsup(user alias) alongsidepush/squash. The full alias list isn't crammed into the error;wt step --help(already augmented byaugment_step_help) is the discovery surface, and theUsage:block points there.Trade-off considered: the old
Unknown alias X (available: …)wording matched the "alias I configured" mental model better. Decided consistency wins —tip:covers typo-suggestion equally well, and a single error format forwt <typo>andwt step <typo>is easier to learn than two.Verified with
cargo run -- hook pre-merge --yes: 3181 tests pass, no lint or doc warnings. Five snapshot updates intests/snapshots/integration__integration_tests__step_alias__*reflect the new format.