Repository navigation
fix(completion): stop offering --dry-run and --var after an alias - #4329
Merged
Merged
Conversation
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.
1 task
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.
wt <alias> --<Tab>(andwt step <alias> --<Tab>) offered--dry-runand--var, but neither does anything useful after an alias.AliasOptions::parserejects--dry-runwith "--dry-runis no longer supported; usewt config alias dry-run <name>instead" (unless the template referencesdry_run), and passes--var KEY=VALUEthrough 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_commandinsrc/completion.rs, a stub that predates alias argument routing (added in #1641;--dry-runwas retired for aliases in #2291 and #2304). This PR removes the stub's own--dry-run,--yesand--vardeclarations, 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 throughmirror_alias_command, which this PR doesn't touch.Test:
test_complete_step_alias_shows_flags, which asserted the stale flags were present, becomestest_complete_step_alias_offers_no_misleading_flagsand asserts--dry-runand--varare absent. It fails onmain(Unexpected --dry-run flag) and passes with the fix. All 80 completion integration tests pass.Not covered:
--yesstill completes after an alias, and so do--configand--verbose, because they are clapglobal = trueflags on the root command and propagate into every subcommand's completions. After an alias they also forward as arguments (the alias parser tests note thatglobal = truedoesn't crossexternal_subcommand). Removing them would mean hiding globals per alias stub, which is a separate decision. The stub's own--yesdeclaration duplicated the global, so dropping it changes nothing.