Skip to content

[feat] CLI-02/C-3: stdin/pipe reading on the sys module#12

Merged
vt128 merged 1 commit into
masterfrom
feat/cli-02-stdin
Jun 21, 2026
Merged

[feat] CLI-02/C-3: stdin/pipe reading on the sys module#12
vt128 merged 1 commit into
masterfrom
feat/cli-02-stdin

Conversation

@vt128

@vt128 vt128 commented Jun 21, 2026

Copy link
Copy Markdown
Member

CLI-02 / C-3 — read piped data from stdin

Per the maintainer's call (data comes from stdin; the script comes from a file
or -c), let scripts consume piped data from standard input. Three
additions to the sys module, mirroring Python's sys.stdin:

function behaviour
sys.read() all of stdin as a string
sys.lines() a lazy iterator over stdin lines (trailing CR/LF trimmed) — a large stream is consumed line by line, not buffered whole; one-shot, like for line in sys.stdin
sys.isatty() whether stdin is a terminal vs a pipe/file (branch interactive vs piped)
load("sys", "lines")
for line in lines():
    print(line.upper())
$ printf 'foo\nbar\n' | ./starcli upper.star
FOO
BAR

No new module or capabilitysys is already wired and classified
CapProcess. Tests redirect os.Stdin through a pipe to cover
read/lines (including a final line with no newline)/isatty. README
documents it. Coverage 75.8% (≥ 65); Docker golang:1.22 green.

This rounds out CLI-02 (STAR-19): check (#9) + args (#11) + stdin now all landed.

Let scripts consume piped DATA from standard input (the script itself still
comes from a file or -c). Three additions to the sys module, mirroring Python's
sys.stdin:

- sys.read()   -> all of stdin as a string.
- sys.lines()  -> a LAZY iterable over stdin lines (trailing CR/LF trimmed), so
  a large stream is consumed line by line, not buffered whole. One-shot: the
  stream drains as it iterates, like 'for line in sys.stdin'.
- sys.isatty() -> whether stdin is a terminal vs a pipe/file, so a script can
  branch on interactive vs piped input.

No new module or capability: sys is already wired and classified CapProcess.
Tests redirect os.Stdin through a pipe to cover read/lines (incl. a final line
with no newline)/isatty. README documents it. Coverage 75.8%; Docker
golang:1.22 green.
@vt128 vt128 merged commit 969e6bc into master Jun 21, 2026
6 checks passed
@vt128 vt128 deleted the feat/cli-02-stdin branch June 21, 2026 08:48
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