Skip to content

fix(completion): stop offering --dry-run and --var after an alias - #4329

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-36826300283-alias-completion
Oct 1, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-36826300283-alias-completion

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

wt <alias> --<Tab> (and wt step <alias> --<Tab>) offered --dry-run and --var, but neither does anything useful after an alias. AliasOptions::parse rejects --dry-run with "--dry-run is no longer supported; use wt config alias dry-run <name> instead" (unless the template references dry_run), and passes --var KEY=VALUE through to the alias as plain positional arguments. Completion was steering users into an error or a flag that silently does nothing.

The flags come from build_alias_completion_command in src/completion.rs, a stub that predates alias argument routing (added in #1641; --dry-run was retired for aliases in #2291 and #2304). This PR removes the stub's own --dry-run, --yes and --var declarations, so the stub declares nothing beyond the alias name and help text. Aliases that wrap a built-in (co = "wt switch {{ args }}") still mirror that built-in's flags through mirror_alias_command, which this PR doesn't touch.

Test: test_complete_step_alias_shows_flags, which asserted the stale flags were present, becomes test_complete_step_alias_offers_no_misleading_flags and asserts --dry-run and --var are absent. It fails on main (Unexpected --dry-run flag) and passes with the fix. All 80 completion integration tests pass.

Not covered: --yes still completes after an alias, and so do --config and --verbose, because they are clap global = true flags on the root command and propagate into every subcommand's completions. After an alias they also forward as arguments (the alias parser tests note that global = true doesn't cross external_subcommand). Removing them would mean hiding globals per alias stub, which is a separate decision. The stub's own --yes declaration duplicated the global, so dropping it changes nothing.

The generic alias completion stub still declared --dry-run, --yes and
--var from before alias arguments were routed by AliasOptions::parse.
Post-alias --dry-run now errors unless the template references dry_run,
and --var forwards to the alias as a plain argument, so completing them
led users into an error or a silently ignored flag.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Oct 1, 2026
@max-sixty
max-sixty merged commit efb4e8b into main Oct 1, 2026
37 of 47 checks passed
@max-sixty
max-sixty deleted the nightly/clean-36826300283-alias-completion branch October 1, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants