Skip to content

feat(cli): promote --yes to a global flag - #2279

Merged
max-sixty merged 4 commits into
mainfrom
yes-global
Apr 18, 2026
Merged

max-sixty merged 4 commits into
mainfrom
yes-global

Conversation

@max-sixty

@max-sixty max-sixty commented Apr 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

-y, --yes is now a top-level global clap flag. It moves off every subcommand's clap args and lives once on Cli, so wt -y <anything>, wt <anything> --yes, and wt --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 — -y should 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 — reads ctx.yes, already threaded via CommandContext::new(..., yes). No change needed; the global now feeds those call sites from handle_*_command in main.rs.
  • approve_command_batch (merge, config hook approvals add) — takes yes: bool. Receives the global.
  • approve_alias_commands — takes yes: bool. Receives global_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 — take yes: bool for confirmation-prompt bypass. All receive the global.

Alias compat

AliasOptions is hand-rolled (not clap) so it doesn't conflict with the clap global. Its post-alias --yes parsing is intentionally preserved here — run_alias does let skip_approval = global_yes || opts.yes; so both wt -y deploy and wt deploy --yes work 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 — new yes: bool on Cli with global = true, short = 'y', help_heading = "Global Options", display_order = 103 (slots after -v). Removed the per-command yes field from SwitchArgs, RemoveArgs, MergeArgs.
  • src/cli/step.rs — removed yes from CommitArgs, SquashArgs, and StepCommand::Prune. Also dropped help_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 — removed yes from all ten hook subcommands (pre-switch, post-switch, pre-start, post-start, pre-commit, post-commit, pre-merge, post-merge, pre-remove, post-remove). --yes stays in KNOWN_HOOK_LONG_FLAGS so the shorthand rewriter still recognizes it as a real flag rather than a template variable.
  • src/cli/config.rs — removed yes from ConfigShellCommand::Install/Uninstall, ConfigCommand::Update (and its now-redundant conflicts_with = "yes" on --print), ConfigPluginsOpencodeCommand::Install/Uninstall, ConfigPluginsClaudeCommand::Install/Uninstall/InstallStatusline.
  • src/main.rs — dispatch_command takes yes: bool; each handle_*_command accepts and threads it. Cli destructure adds yes.
  • src/commands/alias.rs — try_alias, step_alias, run_alias take global_yes: bool. run_alias OR's with opts.yes before calling approve_alias_commands.
  • src/commands/custom.rs — handle_custom_command accepts and passes the global to try_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

  • Does not remove AliasOptions::yes — deferred cleanup per the task brief.
  • Snapshot churn (~27 help files) is the expected fallout of adding a global flag; each subcommand's --help now shows -y, --yes under Global Options.

Test plan

  • 3242 tests pass (cargo run -- hook pre-merge --yes)
  • Lints clean (clippy, cargo fmt, pre-commit)
  • Doc sync test passes after regeneration
  • New approval_ui tests cover before-subcommand, after-subcommand, alias, post-alias, step-alias, and no-approval positions

This was written by Claude Code on behalf of Maximilian

🤖 Generated with Claude Code

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]>
@max-sixty

Copy link
Copy Markdown
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).
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Conflicts resolved in 1dce086a.

The conflicts came from #2282 (approvals moved from hook to config) and #2280 (alias positional args). All four conflict sites:

  • src/main.rs — kept this PR's global yes threading for ConfigCommand::Update and ConfigCommand::Plugins, and added the new ConfigCommand::Approvals arm from main.
  • docs/content/hook.md, skills/worktrunk/reference/hook.md, tests/snapshots/.../help_config_approvals.snap — took main's side; these are regenerated by the doc-sync test.

A follow-up c75d8063 regenerates four doc files and one snapshot so the new global -y, --yes appears under every subcommand's Global Options (wt config approvals included).

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]>
@max-sixty
max-sixty merged commit 1a4eea3 into main Apr 18, 2026
25 checks passed
@max-sixty
max-sixty deleted the yes-global branch April 18, 2026 18:08
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]>
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.

2 participants