Repository navigation
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Clean addition — the flag is well-scoped (picker-only, conflicts with mutually exclusive options) and the implementation is minimal.
Two observations:
-
--printdoesn't guard againstalt-r(remove) — see inline comment. -
No test for the
--printbehavior itself. The help snapshots are updated, but there's no test asserting that--printactually prints and exits without switching. This is hard to test with the TUI picker, but worth noting — a regression here would be silent.
worktrunk-bot
left a comment
There was a problem hiding this comment.
CI is failing on all three platforms with the same error — the check_no_stdout_in_commands output guard rejects println! in command code.
The project requires either using worktrunk::styling::println (for styled output) or adding the file to STDOUT_ALLOWED_PATHS (for intentional data output). Since --print is explicitly data output for scripting, adding "select/mod.rs" to the allowlist is the right fix:
// --print flag: branch name output for scripting
"select/mod.rs",9d7d943 to
2c17d06
Compare
worktrunk-bot
left a comment
There was a problem hiding this comment.
Windows CI fails with field 'print' is never read — handle_select is unix-only, so spec.print is dead code on Windows. The fix is to add it to the existing suppression on line 504:
let _ = (spec.branches, spec.remotes, spec.print);This line isn't in the diff so I can't post an inline suggestion — happy to push a fix commit if that helps.
CI failed on Windows — unused field print on non-unix
worktrunk-bot
left a comment
There was a problem hiding this comment.
CI is failing on all platforms — cargo fmt wants the bail! message split across lines:
anyhow::bail!(
"--print is read-only and cannot be combined with remove (alt-r)"
);(line 332 in src/commands/select/mod.rs)
worktrunk-bot
left a comment
There was a problem hiding this comment.
CI is failing on all platforms — cargo fmt needs the bail! macro reformatted. See inline suggestion.
Opens the interactive picker and prints the selected branch name to stdout without switching. Useful for scripting and automation, e.g. `branch=$(wt switch --print)`.
worktrunk-bot
left a comment
There was a problem hiding this comment.
All previous feedback has been addressed — output guard, Windows suppression, formatting, and the alt-r guard are all handled.
One minor note on the new .expect() at line 329 — see inline comment.
GitHub's dismiss API returns 404 on cross-repository PRs, so the bot cannot undo an approval if CI fails. This left stale approvals contradicting red CI on fork PRs (observed in run 22847633269 on #1404). The fix defers approval to after CI passes for fork PRs, eliminating the stale-approval window entirely. Fixes #1405 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Extract resolve_print_identifier() from picker callback so the --print logic can be tested without an interactive terminal.
|
@max-sixty It's finally ready 😁 |
|
I was trying to think whether there was a way of getting this without adding another option. we could add a shortcut like possibly we could default to this when we run the picker with |
Hmm, if you run |
|
Another option could be, to add this to |
|
@worktrunk-bot can you draft a PR that, if we run |
|
Drafted #1445 — it reuses When |
|
Perfect let's do that one! Thank you 😊 |
## Summary Draft implementation per @max-sixty's [suggestion](#1404 (comment)): reuse `--no-cd` to make the picker print-only instead of adding a separate `--print` flag. - When `wt switch --no-cd` opens the interactive picker (no branch argument), selecting a branch prints its name to stdout and exits — no switching, no cd directive, no hooks - When `wt switch --no-cd <branch>` is used with an explicit branch, behavior is unchanged (switches without cd) - `alt-r` (remove) is blocked in print mode since it's a read-only operation This avoids adding a new CLI flag while giving the same scripting capability that #1404 proposed. ## Test plan - [x] Unit tests for `resolve_print_identifier` (switch, create, remove cases) - [x] PTY integration test: `--no-cd` picker prints branch name, emits no cd directive - [x] Existing `--no-cd` tests still pass (directive suppression, hooks, execute) - [x] Help snapshots and doc sync updated 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
First of all, thanks for this great project! I just started with it a few days ago and I love it!!
I'd like to be able to script a bit more and thought it would be nice to include a
--printoption to thewt switchcommand.It opens the interactive picker and then when you press enter, it prints the selected working tree back. This can be used to automate/script things easier for custom workflows.
Curious what you think :)