Skip to content

feat: add --output <file> flag to write results to a file#115

Merged
vmvarela merged 2 commits intomasterfrom
issue-87/add-output-flag
Apr 29, 2026
Merged

feat: add --output <file> flag to write results to a file#115
vmvarela merged 2 commits intomasterfrom
issue-87/add-output-flag

Conversation

@vmvarela
Copy link
Copy Markdown
Owner

Summary

Closes #87

  • Adds --output <path> flag that writes results to a file instead of stdout
  • Compatible with all output modes: CSV (default), --json, --header
  • Exits with code 1 and a clear error message if the file cannot be created
  • Documents the flag in --help, README.md, and docs/sql-pipe.1.scd
  • Adds 3 integration tests (basic file output, JSON output to file, bad path → exit 1)

Example

cat input.csv | sql-pipe --output results.csv 'SELECT * FROM t'
cat input.csv | sql-pipe --json --output report.json 'SELECT region, SUM(revenue) FROM t GROUP BY region'

@vmvarela vmvarela added the type:feature New functionality label Apr 29, 2026
@github-actions github-actions Bot added type:chore Maintenance, refactoring, tooling type:docs Documentation only labels Apr 29, 2026
- flush stdout_writer before fatalSqlWithContext when execQuery fails
  mid-execution (prevents partial buffered rows being lost on SQL error)
- reject --output + --columns at parse time with clear error message
- validate --output value for empty/whitespace in both space and equals forms
- update --columns help text to document --output exclusion
- add tests 45-47: --output+--header, --output+--columns rejection,
  --output SQL error exit code
@vmvarela vmvarela merged commit eeb626d into master Apr 29, 2026
4 checks passed
@vmvarela vmvarela deleted the issue-87/add-output-flag branch April 29, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Maintenance, refactoring, tooling type:docs Documentation only type:feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --output <file> flag to write results to a file

1 participant