Skip to content

Commit dccae85

Browse files
worktrunk-botclaude
andcommitted
refactor: hide --cd flag, keep --no-cd as the visible flag
Use the same overrides_with + hide pattern as --progressive/--no-progressive. The --cd flag still works but is hidden from help output, keeping the CLI surface clean while --no-cd documents the override. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 5472a27 commit dccae85

5 files changed

Lines changed: 9 additions & 25 deletions

File tree

‎docs/content/switch.md‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,12 @@ Usage: <b><span class=c>wt switch</span></b> <span class=c>[OPTIONS]</span> <spa
211211
<b><span class=c>--clobber</span></b>
212212
Remove stale paths at target
213213

214-
<b><span class=c>--cd</span></b>
215-
Change directory after switching
216-
217-
Overrides <b>[switch] no-cd = true</b> in config.
218-
219214
<b><span class=c>--no-cd</span></b>
220215
Skip directory change after switching
221216

222217
Hooks still run normally. Useful when hooks handle navigation (e.g.,
223218
tmux workflows) or for CI/automation. Can be set as default via
224-
[switch] no-cd = true in config.
219+
[switch] no-cd = true in config. Use <b>--cd</b> to override.
225220

226221
<b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
227222
Print help (see a summary with &#39;-h&#39;)

‎skills/worktrunk/reference/switch.md‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,12 @@ Usage: <b><span class=c>wt switch</span></b> <span class=c>[OPTIONS]</span> <spa
181181
<b><span class=c>--clobber</span></b>
182182
Remove stale paths at target
183183

184-
<b><span class=c>--cd</span></b>
185-
Change directory after switching
186-
187-
Overrides <b>[switch] no-cd = true</b> in config.
188-
189184
<b><span class=c>--no-cd</span></b>
190185
Skip directory change after switching
191186

192187
Hooks still run normally. Useful when hooks handle navigation (e.g.,
193188
tmux workflows) or for CI/automation. Can be set as default via
194-
[switch] no-cd = true in config.
189+
[switch] no-cd = true in config. Use <b>--cd</b> to override.
195190

196191
<b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
197192
Print help (see a summary with &#39;-h&#39;)

‎src/cli/mod.rs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,16 @@ To change which branch a worktree is on, use `git switch` inside that worktree.
446446
#[arg(long, requires = "branch")]
447447
clobber: bool,
448448

449-
/// Change directory after switching
450-
///
451-
/// Overrides `[switch] no-cd = true` in config.
452-
#[arg(long, conflicts_with = "no_cd")]
449+
/// Force directory change after switching
450+
#[arg(long = "cd", overrides_with = "no_cd", hide = true)]
453451
cd: bool,
454452

455453
/// Skip directory change after switching
456454
///
457455
/// Hooks still run normally. Useful when hooks handle navigation
458456
/// (e.g., tmux workflows) or for CI/automation. Can be set as default
459-
/// via `[switch] no-cd = true` in config.
460-
#[arg(long, conflicts_with = "cd")]
457+
/// via `[switch] no-cd = true` in config. Use `--cd` to override.
458+
#[arg(long, overrides_with = "cd")]
461459
no_cd: bool,
462460

463461
/// Skip approval prompts

‎tests/snapshots/integration__integration_tests__help__help_switch_long.snap‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ info:
88
env:
99
CLICOLOR_FORCE: "1"
1010
COLUMNS: "500"
11+
GIT_EDITOR: ""
1112
LANG: C
1213
LC_ALL: C
1314
NO_COLOR: ""
@@ -73,15 +74,10 @@ Usage: wt switch [OPTIONS] [BRANCH] [--
7374
--clobber
7475
Remove stale paths at target
7576

76-
--cd
77-
Change directory after switching
78-
79-
Overrides [switch] no-cd = true in config.
80-
8177
--no-cd
8278
Skip directory change after switching
8379

84-
Hooks still run normally. Useful when hooks handle navigation (e.g., tmux workflows) or for CI/automation. Can be set as default via [1m[switch] no-cd = true[0m in config.[0m
80+
Hooks still run normally. Useful when hooks handle navigation (e.g., tmux workflows) or for CI/automation. Can be set as default via [1m[switch] no-cd = true[0m in config. Use [1m--cd[0m to override.[0m
8581

8682
-h, --help
8783
Print help (see a summary with '-h')

‎tests/snapshots/integration__integration_tests__help__help_switch_short.snap‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ info:
88
env:
99
CLICOLOR_FORCE: "1"
1010
COLUMNS: "500"
11+
GIT_EDITOR: ""
1112
LANG: C
1213
LC_ALL: C
1314
NO_COLOR: ""
@@ -43,7 +44,6 @@ Usage: wt switch [OPTIONS] [BRANCH] [--
4344
-b, --base <BASE> Base branch
4445
-x, --execute <EXECUTE> Command to run after switch
4546
--clobber Remove stale paths at target
46-
--cd Change directory after switching
4747
--no-cd Skip directory change after switching
4848
-h, --help Print help (see more with '--help')
4949

0 commit comments

Comments
 (0)