Skip to content

Unify wt step <typo> errors with clap-native format - #2215

Merged
max-sixty merged 1 commit into
mainfrom
step-clap-errors
Apr 14, 2026
Merged

max-sixty merged 1 commit into
mainfrom
step-clap-errors

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #2212. That PR restored clap-native errors for top-level wt <typo>; this one applies the same treatment one level down so wt step <typo> reads identically.

The three custom bail! branches in step_alias (Unknown step command X — perhaps Y?, Unknown step command X (no aliases configured), Unknown alias X (available: …)) are replaced by a synthesized clap::Error{InvalidSubcommand} routed through enhance_and_exit_error. Output now reads:

error: unrecognized subcommand 'sqush'

  tip: some similar subcommands exist: 'squash', 'push'

Usage: wt step <COMMAND>

For more information, try '--help'.

Exit code is 2 (clap convention) instead of 1.

User-configured aliases are fed into SuggestedSubcommand, so a typo like wt step deplyo still suggests deploy when deploy is a user alias — wt step u suggests up (user alias) alongside push/squash. The full alias list isn't crammed into the error; wt step --help (already augmented by augment_step_help) is the discovery surface, and the Usage: 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 for wt <typo> and wt 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 in tests/snapshots/integration__integration_tests__step_alias__* reflect the new format.

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]>
@max-sixty
max-sixty merged commit 372ce68 into main Apr 14, 2026
21 of 22 checks passed
@max-sixty
max-sixty deleted the step-clap-errors branch April 14, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant