Skip to content

Read the trace from stdin when the file argument is - - #24

Merged
jackfranklin merged 2 commits into
ChromeDevTools:mainfrom
nucliweb:read-trace-from-stdin
Nov 25, 2026
Merged

jackfranklin merged 2 commits into
ChromeDevTools:mainfrom
nucliweb:read-trace-from-stdin

Conversation

@nucliweb

Copy link
Copy Markdown
Contributor

Every command that takes a single trace file accepts - as the file to read the trace from stdin. Plain JSON and gzip data are both accepted, so cat trace.json.gz | trace-engine-cli - and curl -s <url> | trace-engine-cli tasks - --top 5 work without a temporary file. scan still reads files and directories only.

An empty stdin fails with "No trace data received on stdin." When stdin is an interactive terminal, the command fails right away with an example of how to pipe a trace, instead of waiting for input.

yargs re-parses positionals as --file - and does not take a lone - as a value, so it passed an empty string to the command. The CLI replaces a lone - with a placeholder before parsing and restores it in a middleware, so no command definition changes.

Loader tests cover JSON and gzip from stdin, empty stdin and an interactive terminal. A CLI test runs the binary with a piped trace. Verified with npm run check, npm run build, npm test and real pipes, where the output matches reading the same file.

Implements the stdin input proposed in #9.

nucliweb and others added 2 commits November 24, 2026 19:35
Every command that takes a single trace file accepts `-` to read the trace from stdin, as plain JSON or gzip data. An empty stdin or an interactive terminal fails with a clear message instead of waiting for input.

yargs re-parses positionals as `--file -` and does not take a lone `-` as a value, so the CLI replaces it with a placeholder before parsing and restores it in a middleware.
@jackfranklin
jackfranklin merged commit 6601cad into ChromeDevTools:main Nov 25, 2026
9 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