Skip to content

feat: add --columns flag to list CSV input column names#113

Merged
vmvarela merged 3 commits intomasterfrom
issue-85/add-columns-flag
Apr 29, 2026
Merged

feat: add --columns flag to list CSV input column names#113
vmvarela merged 3 commits intomasterfrom
issue-85/add-columns-flag

Conversation

@vmvarela
Copy link
Copy Markdown
Owner

Summary

  • Adds --columns mode: reads only the CSV header row, prints each column name on its own line, exits 0
  • With -v/--verbose, also shows the inferred type per column (e.g. id INTEGER, amount REAL)
  • Mutually exclusive with a query argument — exits 1 with a clear error message
  • Respects --delimiter and --tsv flags

Changes

  • src/main.zig: new ColumnsArgs struct, .columns variant in ArgsResult, --columns parsing in parseArgs, runColumns() function, updated printUsage()
  • build.zig: 5 new integration tests (basic output, verbose types, delimiter, tsv, error case)
  • README.md: new --columns row in the Flags table
  • docs/sql-pipe.1.scd: new --columns OPTIONS entry; updated SYNOPSIS with second invocation form

Acceptance Criteria

  • --columns reads only the CSV header row, prints each column name on its own line to stdout, and exits 0
  • Inferred type shown with --columns --verbose: id INTEGER, amount REAL, region TEXT
  • --columns is mutually exclusive with a query argument (prints usage error if both provided)
  • Works with --delimiter and --tsv flags
  • Documented in --help, README.md Flags table, and docs/sql-pipe.1.scd
  • Test: correct column list printed, correct exit code

Closes #85

Adds --columns mode that reads only the CSV header row from stdin,
prints each column name on its own line to stdout, and exits 0.

- With -v/--verbose, shows inferred type per column (name INTEGER)
  using the first 100 data rows for inference
- Mutually exclusive with a query argument (exits 1 with error)
- Respects --delimiter and --tsv flags
- 5 integration tests added (basic, verbose, delimiter, tsv, error)
- Documented in --help, README.md Flags table, and docs/sql-pipe.1.scd

Closes #85
@github-actions github-actions Bot added type:feature New functionality type:chore Maintenance, refactoring, tooling type:docs Documentation only labels Apr 29, 2026
- Replace 'catch break' with proper CSV error reporting in runColumns
  verbose path; malformed data rows now exit 2 with row number instead
  of silently inferring all types as TEXT
- Document dual --verbose behavior in printUsage: row count in query
  mode, inferred types in --columns mode
- Add integration tests 38-41: malformed CSV in verbose mode (exit 2),
  header-only input (all TEXT), empty stdin (exit 2), -v alias
@vmvarela vmvarela merged commit 09d2183 into master Apr 29, 2026
4 checks passed
@vmvarela vmvarela deleted the issue-85/add-columns-flag branch April 29, 2026 15:26
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 --columns flag to list input column names

1 participant