Skip to content

nessie-cli: add --stdout / -S for stream-backed terminal (#10865)#12431

Merged
dimas-b merged 2 commits into
projectnessie:mainfrom
mj006648:cli-stdout-posix
May 26, 2026
Merged

nessie-cli: add --stdout / -S for stream-backed terminal (#10865)#12431
dimas-b merged 2 commits into
projectnessie:mainfrom
mj006648:cli-stdout-posix

Conversation

@mj006648

Copy link
Copy Markdown
Contributor

Follow-up to #12425, addressing the underlying PTY-vs-stream issue from #10865 that the --plain alias didn't fix. As discussed in #12425 (comment).

Adds a new --stdout / -S option. When set, builds the jline terminal as:

TerminalBuilder.builder()
    .jansi(false)
    .system(false)
    .streams(System.in, System.out)
    .type("dumb")
    .build();

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 --plain since 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.txt scenario from the issue body now works). :nessie-cli:test and :spotlessCheck pass. 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.

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
dimas-b previously approved these changes May 25, 2026

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for your contribution, @mj006648 ! This PR LGTM with minor comments.

Comment thread cli/cli/src/main/java/org/projectnessie/nessie/cli/cli/NessieCliImpl.java Outdated
@dimas-b dimas-b enabled auto-merge (squash) May 26, 2026 16:26
@dimas-b dimas-b merged commit dc629fb into projectnessie:main May 26, 2026
16 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.

2 participants