Repository navigation
feat(cli): promote --yes to a global flag - #2279
Merged
Merged
Conversation
worktrunk-bot
approved these changes
Apr 18, 2026
Move `-y, --yes` from being duplicated across per-command clap args (switch, remove, merge, commit, squash, prune, all hook subcommands, config shell install/uninstall, config update, plugin install/uninstall) to a single top-level global. `wt -y <anything>` now skips any approval or confirmation prompt for that invocation. Threaded the global through `dispatch_command` into each handler. Alias dispatch (`try_alias`, `step_alias`, `run_alias`) accepts the global and OR's with `AliasOptions::yes` so both `wt -y deploy` and the post-alias `wt deploy --yes` still work — the hand-rolled alias parser stays intact for now (separate cleanup). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Apr 18, 2026
Owner
Author
|
@worktrunk-bot resoove conflicts |
# Conflicts: # docs/content/hook.md # skills/worktrunk/reference/hook.md # src/main.rs # tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
Regenerates command docs and help_config_approvals snapshot to reflect the global -y, --yes flag now surfaced under every subcommand (including the new wt config approvals introduced on main).
Collaborator
|
Conflicts resolved in 1dce086a. The conflicts came from #2282 (approvals moved from
A follow-up c75d8063 regenerates four doc files and one snapshot so the new global All required checks pass. |
After promoting --yes to a global flag, the Automation heading on step commit, step squash, step for-each, and step prune contained a single flag each. A group with one item is just visual noise — the flags now render under the default Options block. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 18, 2026
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
PR #2279 promoted -y/--yes to a top-level global clap flag, but AliasOptions::parse kept consuming a post-alias --yes for back-compat. Remove that path so global_yes is the single source for skip_approval. Why a real cutover, not a no-op: clap's global = true does not propagate flags across an external_subcommand boundary (verified against clap 4.6), so wt deploy --yes was never reaching the global parser — it only worked because the hand-rolled parser consumed it. Removing the field is a user-visible removal of the post-alias form. Use wt -y deploy or wt --yes deploy (pre-alias) instead. The post-alias --yes now errors as an unknown flag; -y (single-dash) silently becomes a {{ args }} positional. Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
PR #2279 promoted `-y`/`--yes` to a top-level global clap flag. The hand-rolled `AliasOptions::parse` kept consuming a post-alias `--yes` for back-compat — that's the deferred cleanup landing here. `run_alias` now reads only the global flag (`skip_approval = global_yes`). This is a real cutover, not a no-op. Clap's `global = true` does not propagate flags across an `external_subcommand` boundary (verified against clap 4.6 — `wt deploy --yes` results in `Custom(["deploy", "--yes"])` with `global_yes = false`). So the post-alias form was never reaching the global parser; it only worked because `AliasOptions::parse` consumed it. Removing the field removes user-visible behavior: | Form | Before | After | |---|---|---| | `wt -y deploy` | skips approval | skips approval | | `wt --yes deploy` | skips approval | skips approval | | `wt deploy --yes` | skips approval | errors: "Unknown flag '--yes'" | | `wt deploy -y` | skips approval | silently forwards `-y` as `{{ args }}` positional | The `--yes` / `-y` asymmetry on the post-alias side is documented in the `AliasOptions::parse` docstring and locked in by parser tests. ## Test changes - `test_post_alias_yes_still_works` → `test_post_alias_yes_no_longer_supported` (asserts the new error) - 14 call sites in `tests/integration_tests/step_alias.rs` migrated from `&[..., "--yes"]` to `make_snapshot_cmd_with_global_flags(..., &["-y"])` - 4 unnecessary `--yes` flags removed from `tests/integration_tests/bare_repository.rs` (the `print-repo-path` user-config alias never required approval) > _This was written by Claude Code on behalf of Maximilian_ Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 18, 2026
Resolves conflicts with main's two major landings since the branch diverged: - Global `-y`/`--yes` flag (PR #2279): `AliasOptions` no longer carries a `yes` field — approval skip comes from the top-level global. The post-alias `--yes` form now errors as an unknown flag, and post-alias `-y` falls into the positional-args branch. - Approvals module split (PR #2282): `add_approvals` / `clear_approvals` moved from `hook_commands` into `src/commands/config/approvals.rs`. The alias changes in this branch are compatible with both landings: - `AliasOptions` drops both `dry_run` and `yes`, keeping only `name`, `vars`, and `positional_args`. - `run_alias` uses `global_yes` from main's signature as the sole source for skipping approval. - `--dry-run` remains a parser-level error pointing at `wt config alias dry-run <name>`. - Existing `wt config alias dry-run` integration tests dropped the unused `-y` flag — dry-run never needs approval because it doesn't execute. Co-Authored-By: Claude Opus 4.7 (1M context) <[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.
Summary
-y, --yesis now a top-level global clap flag. It moves off every subcommand's clap args and lives once onCli, sowt -y <anything>,wt <anything> --yes, andwt --yes <anything>all skip any approval or confirmation prompt for that invocation.Why
Follow-up to the top-level alias dispatch (#2266). The long-term plan is to unify approval-bypass behavior —
-yshould be a true global rather than duplicated across switch, remove, merge, commit, squash, prune, all ten hook subcommands, shell install/uninstall, plugin install/uninstall, and config update. A single canonical flag removes ~50 lines of duplicated clap definitions and one source of drift.Call-site survey
Approval and confirmation prompt sources, as surfaced by
rg -l 'approve_|requires_approval|confirm_':approve_hooks/approve_hooks_filtered— readsctx.yes, already threaded viaCommandContext::new(..., yes). No change needed; the global now feeds those call sites fromhandle_*_commandinmain.rs.approve_command_batch(merge, confighook approvals add) — takesyes: bool. Receives the global.approve_alias_commands— takesyes: bool. Receivesglobal_yes || opts.yes(see "Alias compat" below).handle_configure_shell/handle_unconfigure_shell/handle_config_update/handle_claude_install[_statusline]/handle_claude_uninstall/handle_opencode_install/handle_opencode_uninstall— takeyes: boolfor confirmation-prompt bypass. All receive the global.Alias compat
AliasOptionsis hand-rolled (not clap) so it doesn't conflict with the clap global. Its post-alias--yesparsing is intentionally preserved here —run_aliasdoeslet skip_approval = global_yes || opts.yes;so bothwt -y deployandwt deploy --yeswork unchanged. Removing the post-alias form is a separate cleanup, tracked by the user's long-term simplification plan.Navigating the diff
src/cli/mod.rs— newyes: boolonCliwithglobal = true,short = 'y',help_heading = "Global Options",display_order = 103(slots after-v). Removed the per-commandyesfield fromSwitchArgs,RemoveArgs,MergeArgs.src/cli/step.rs— removedyesfromCommitArgs,SquashArgs, andStepCommand::Prune. Also droppedhelp_heading = "Automation"from the four step subcommands where the group was left with a single flag (commit,squash,for-each,prune); those flags now render under default Options instead of a single-item group.src/cli/hook.rs— removedyesfrom all ten hook subcommands (pre-switch,post-switch,pre-start,post-start,pre-commit,post-commit,pre-merge,post-merge,pre-remove,post-remove).--yesstays inKNOWN_HOOK_LONG_FLAGSso the shorthand rewriter still recognizes it as a real flag rather than a template variable.src/cli/config.rs— removedyesfromConfigShellCommand::Install/Uninstall,ConfigCommand::Update(and its now-redundantconflicts_with = "yes"on--print),ConfigPluginsOpencodeCommand::Install/Uninstall,ConfigPluginsClaudeCommand::Install/Uninstall/InstallStatusline.src/main.rs—dispatch_commandtakesyes: bool; eachhandle_*_commandaccepts and threads it.Clidestructure addsyes.src/commands/alias.rs—try_alias,step_alias,run_aliastakeglobal_yes: bool.run_aliasOR's withopts.yesbefore callingapprove_alias_commands.src/commands/custom.rs—handle_custom_commandaccepts and passes the global totry_alias.docs/content/+skills/worktrunk/reference/— auto-generated from--help-page; the global appears under "Global Options" on every subcommand.tests/integration_tests/approval_ui.rs— six new tests:test_global_yes_before_subcommand,test_global_yes_for_hook,test_global_yes_for_alias,test_post_alias_yes_still_works,test_global_yes_for_step_alias,test_global_yes_on_command_without_approval.Notes
AliasOptions::yes— deferred cleanup per the task brief.--helpnow shows-y, --yesunder Global Options.Test plan
cargo run -- hook pre-merge --yes)🤖 Generated with Claude Code