Repository navigation
feat: add shell completion for step aliases - #1641
Merged
Merged
Conversation
Aliases configured in user/project config now appear as completable subcommands when tab-completing `wt step <TAB>`. Each alias subcommand includes --dry-run, --yes, and --var flags. Aliases that shadow built-in step commands are skipped to avoid duplicates. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Mar 21, 2026
This was referenced Mar 21, 2026
Cover the truncation path (>60 chars) and multi-byte char boundary handling that codecov flagged as uncovered. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Mar 21, 2026
max-sixty
pushed a commit
that referenced
this pull request
Oct 1, 2026
) `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. Co-authored-by: worktrunk-bot <[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.
Aliases configured in user/project config now appear as completable subcommands when tab-completing
wt step <TAB>. Previously, only built-in step commands (commit, push, rebase, etc.) appeared since aliases are dynamic — they're resolved at runtime via theexternal_subcommandcatch-all, which clap's completion engine doesn't know about.The fix injects alias names as synthetic clap subcommands in the completion-only command tree. Each alias subcommand includes
--dry-run,--yes/-y, and--varflags matching the real alias flag parser. Aliases that shadow built-in step commands are skipped. Shells that support it (fish, zsh) show the alias template as help text.