Stream downloads to stdout with --output - - #13
Merged
Conversation
`transcripts download <id> > f.json` used to capture the string "Saved transcripts-<id>.json" while the document landed in a file the caller never asked for. Two fixes, both needed: --output - streams the document bytes to stdout and writes nothing else, so the redirect captures the document. The confirmation moves to stderr unconditionally, so even the default file-writing path leaves a redirect clean. Also close the output file explicitly and report a close error: a failed flush on a 1 MB transcript used to be silently swallowed by the deferred Close. Closes #7 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #7. Stacked on #12 (review the last commit only).
Before
After
And the default path no longer pollutes a redirect either:
Change
--output -streams the document to stdout and prints nothing else.Saved <path>confirmation goes to stderr unconditionally. Both halves are needed:--output -serves people who want a pipe, stderr serves everyone who redirects without knowing the flag exists.--helpfor every download-capable resource now spells out all three behaviours, since "downloads always write a file" was the part nobody knew.I went with the explicit
-rather than auto-detecting a non-TTY stdout. Auto-detection would mean the same command writes a file when run interactively and no file when redirected, which is a surprising thing to debug; the stderr move already fixes the reported damage for people who never read the flag.While in there: the output file is now closed explicitly with its error reported. A failed flush on a 1 MB transcript was silently swallowed by the deferred
Close, so a truncated download could exit 0.Tests
--output -puts the exact bytes on stdout, leaves stderr empty, and writes no file to the working directory; the default path leaves stdout empty and reports the path on stderr.🤖 Generated with Claude Code