[feat] CLI-02/C-3: stdin/pipe reading on the sys module#12
Merged
Conversation
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.
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.
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. Threeadditions to the
sysmodule, mirroring Python'ssys.stdin:sys.read()sys.lines()for line in sys.stdinsys.isatty()No new module or capability —
sysis already wired and classifiedCapProcess. Tests redirectos.Stdinthrough a pipe to coverread/lines(including a final line with no newline)/isatty. READMEdocuments it. Coverage 75.8% (≥ 65); Docker
golang:1.22green.This rounds out CLI-02 (STAR-19): check (#9) + args (#11) + stdin now all landed.