nessie-cli: add --stdout / -S for stream-backed terminal (#10865)#12431
Merged
Conversation
Closes projectnessie#10865. Follow-up to projectnessie#12425 (which added --plain / -P as a discoverability alias for --non-ansi). That change made the ANSI-free output mode easier to find but did not address the underlying redirection bug: jline's default TerminalBuilder opens the controlling PTY (/dev/tty on POSIX) when a TTY is detected, so 'nessie-cli -c "..." > file' still wrote to the terminal instead of the file. This change adds a new --stdout / -S option that builds the jline Terminal with .system(false).streams(System.in, System.out).type("dumb"). The stream-backed Terminal honours shell redirection (>) and pipes (|) in non-interactive runs (-c, -s) and emits no ANSI control sequences, so the redirected file / piped consumer stays clean. The option is intentionally separate from --plain: --plain / --non-ansi : ANSI control on/off (existing behaviour) --stdout : stream routing (new, implies plain) This matches the orthogonal concerns called out in the projectnessie#12425 review discussion. Signed-off-by: mj006648 <uckdekf@gmail.com>
dimas-b
previously approved these changes
May 25, 2026
dimas-b
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #12425, addressing the underlying PTY-vs-stream issue from #10865 that the
--plainalias didn't fix. As discussed in #12425 (comment).Adds a new
--stdout/-Soption. When set, builds the jline terminal as:system(false).streams(...)gives a stream-backed Terminal that follows redirected streams without opening/dev/tty.type("dumb")suppresses ANSI without going through.dumb(true).provider(DUMB), which re-triggers a TTY lookup and fails the same way on a redirected stdout.Kept separate from
--plainsince the concerns are orthogonal:--plain/--non-ansi— ANSI on/off (existing)--stdout— stream routing (new, implies plain)Verified locally against a real Nessie server (the exact
-c "SHOW LOG" > /tmp/log.txtscenario from the issue body now works).:nessie-cli:testand:spotlessCheckpass. Tested on Linux; should be OS-agnostic but unverified on Windows / macOS.Did not change the default (no-flag) behaviour, which still crashes on redirected stdout — that seemed like a separate discussion. Happy to fold it in if you'd rather.