Skip to content

feat: add checked stdout writer to cli - #77

Merged
HaoZeke merged 1 commit into
developfrom
feat/cli-checked-stdout
Nov 21, 2026
Merged

HaoZeke merged 1 commit into
developfrom
feat/cli-checked-stdout

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

cli.put, cli.print, and cli.out ignore write errors, which suits
progress messages while leaving callers that capture or evaluate
standard output unaware of EBADF, EPIPE, or ENOSPC. Front ends
that emit both line-by-line output and captured payloads had to keep a
local checked-write helper and failure flag.

Add cli.Stdout (write, print, and finish) and one-shot
cli.writeOut to zig_common.cli:

  • On the first failed write, Stdout latches failed, prints
    TOOL: cannot write output (ERRNO) once to err_fd, and returns
    false.
  • Later calls return false without repeating the message, and
    Stdout.finish maps exit status 0 to 1 while preserving nonzero
    statuses.

Verification

  • zig fmt formatting check across build.zig, build.zig.zon,
    src, and tests.
  • zig build test unit suite, including Stdout and writeOut cases
    for short and heap-allocated writes, EBADF, /dev/full (ENOSPC),
    and exit status conversion.
  • JSON, Python text, filesystem, and lock parity suites plus
    towncrier changelog draft build.

cli.put, cli.print, and cli.out ignore write failures, which suits
diagnostic output on stderr while leaving callers that capture or
evaluate stdout unaware of EBADF or ENOSPC. Front ends that print both
multi-line status and captured documents had to maintain their own
write wrapper and sticky failure flag.

Add cli.Stdout with write, print, and finish methods plus one-shot
cli.writeOut. On the first write failure, Stdout sets failed, prints
"TOOL: cannot write output (ERRNO)" on err_fd, and returns false; later
writes return false without repeating the diagnostic, and finish turns
exit status 0 into 1.

Tests cover short and heap-formatted writes, sticky EBADF and ENOSPC
reporting, exit status conversion, and cli.writeOut on /dev/full.
@HaoZeke
HaoZeke changed the base branch from feat/keep-above-stdio to develop November 21, 2026 05:36
@HaoZeke
HaoZeke merged commit 3119105 into develop Nov 21, 2026
8 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