Skip to content

Fix wt exit command to output to stdout#4

Merged
agarcher merged 1 commit intomainfrom
exit-bug
Jan 11, 2026
Merged

Fix wt exit command to output to stdout#4
agarcher merged 1 commit intomainfrom
exit-bug

Conversation

@agarcher
Copy link
Owner

Summary

  • Fixed wt exit (and other commands) to output paths to stdout instead of stderr
  • Cobra's cmd.Println() writes to stderr by default, which breaks shell wrappers that capture stdout
  • Changed all path outputs to use fmt.Fprintln(cmd.OutOrStdout(), ...)
  • Added tests to verify path output goes to stdout, not stderr
  • Updated CLAUDE.md with documentation of this Cobra gotcha

Test plan

  • Verified wt exit now works with shell wrapper
  • All existing tests pass
  • Added new tests for exit from worktree and stdout verification

🤖 Generated with Claude Code

Cobra's cmd.Println() and cmd.Printf() write to stderr by default,
which breaks shell wrappers that capture stdout for path output.

Changed all path outputs to use fmt.Fprintln(cmd.OutOrStdout(), ...)
to ensure shell wrappers can capture the output correctly.

Files fixed:
- exit.go: main repo path output
- root_path.go: main repo path output
- cd.go: worktree path output
- create.go: worktree path output (last line)
- list.go: worktree listing output
- root.go: version output

Also:
- Added tests to verify path output goes to stdout
- Updated CLAUDE.md with documentation of this Cobra gotcha

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@agarcher agarcher merged commit 76e8911 into main Jan 11, 2026
4 checks passed
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.

1 participant