Repository navigation
Route --help output to stdout - #2155
Conversation
Matches POSIX convention (cargo, curl, python, git <cmd> -h) and aligns with --version (#2072). Previously help went to stderr with the rationale "stdout is reserved for data output", but `show_help_in_pager` was shared with `wt config show`, `wt hook show`, and `wt config state` — all data outputs now also move to stdout, where they should have been. User-visible behavior change: scripts doing `wt --help 2>/dev/null | x` will see help on stdout rather than discarding it. `wt --help > file` now captures help instead of producing a blank file. Also simplified the pager TTY guard to check only stdout — the stderr check was a leftover from the `>&2` redirect era. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
# Conflicts: # tests/snapshots/integration__integration_tests__help__help_config_shell.snap # tests/snapshots/integration__integration_tests__help__help_config_short.snap # tests/snapshots/integration__integration_tests__help__help_list_short.snap # tests/snapshots/integration__integration_tests__help__help_merge_short.snap # tests/snapshots/integration__integration_tests__help__help_no_args.snap # tests/snapshots/integration__integration_tests__help__help_remove_short.snap # tests/snapshots/integration__integration_tests__help__help_root_short.snap # tests/snapshots/integration__integration_tests__help__help_step_short.snap # tests/snapshots/integration__integration_tests__help__help_switch_short.snap # tests/snapshots/integration__integration_tests__step_alias__step_help_includes_aliases.snap # tests/snapshots/integration__integration_tests__step_alias__step_list_no_aliases.snap # tests/snapshots/integration__integration_tests__step_alias__step_list_with_aliases.snap
Main added new config_show deprecation snapshots and tweaked `-v` help text; re-run captures content with our stdout routing applied. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Switch help_pager fallback prints from std::print! to the anstream-based worktrunk::styling::print — stdlib prints the styled string verbatim, so `wt --help > file` or `wt --help | less` was leaking raw escape sequences instead of plain text. Found by Codex review. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
One stale docstring in src/help_pager.rs — the TTY check was simplified to stdout-only but the bullet list still mentions stderr.
|
The uncovered diff lines in
Each of these is I'd treat this as a false-positive-ish codecov/patch fail, but leaving the call to you. |
The bullet list said "Neither stdout nor stderr is a TTY" but the check was simplified to stdout only. Flagged by worktrunk-bot review on #2155. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
# Conflicts: # tests/integration_tests/config_state.rs
Three tests in config_state.rs were asserting on stderr with empty inline snapshots — they kept passing after PR #2155 moved state output from stderr to stdout, but no longer verified anything. Switch the assertions to stdout and capture the real content. Co-Authored-By: Claude <[email protected]>
Three tests in `tests/integration_tests/config_state.rs` were asserting on `stderr` with empty inline snapshots — they kept passing after #2155 moved `wt config state` output from stderr to stdout, but no longer verified anything. This swaps the assertions to `stdout` and captures the real content. Affected tests: `test_state_get_empty`, `test_state_get_logs_empty`, `test_state_get_logs_dir_exists_no_log_files`. > _This was written by Claude Code on behalf of Maximilian._ Co-authored-by: Claude <[email protected]>
Worktrunk sent all help output to stderr. This is an outlier versus most CLIs (cargo, curl, python,
git <cmd> -h— all stdout) and versus--version, which moved to stdout in #2072 for the same reasons. Move help to stdout and canonicalize the shared pager function so its other callers (wt config show,wt hook show,wt config state) emit on stdout too.The prior rationale — "stdout is reserved for data output" so
wt config show | jqworks — was already self-contradictory:config showwent through the same pager helper and was landing on stderr.What changed
src/help_pager.rs— removed the>&2pager redirect and switched fallback prints fromstd::print!to the anstream-awareworktrunk::styling::print, so piped/redirected output is plain text rather than raw ANSI. Simplified the TTY guard to check stdout only (thestdout OR stderrcheck was a leftover from the redirect era).src/help.rs— DisplayHelp fallback prints viastyling::println.src/commands/config/{show,state}.rs,src/commands/hook_commands.rs— pager fallbacks print to stdout.test_help_goes_to_stdoutandtest_help_strips_ansi_when_pipedas regression anchors (parallel to existingtest_version_goes_to_stdout). Verified the ANSI test catches the bug by reverting temporarily.----- stderr -----section to----- stdout -----.User-visible behavior change
Scripts that did
wt --help 2>/dev/null | xpreviously discarded help and piped nothing; they now pipe the help text.wt --help > filecaptures help instead of leaving the file blank. Both changes align Worktrunk with POSIX conventions. Terminal usage (pager on TTY) is unchanged.