feat: add --columns flag to list CSV input column names#113
Merged
Conversation
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
- 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
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.
Summary
--columnsmode: reads only the CSV header row, prints each column name on its own line, exits 0-v/--verbose, also shows the inferred type per column (e.g.id INTEGER,amount REAL)--delimiterand--tsvflagsChanges
src/main.zig: newColumnsArgsstruct,.columnsvariant inArgsResult,--columnsparsing inparseArgs,runColumns()function, updatedprintUsage()build.zig: 5 new integration tests (basic output, verbose types, delimiter, tsv, error case)README.md: new--columnsrow in the Flags tabledocs/sql-pipe.1.scd: new--columnsOPTIONS entry; updated SYNOPSIS with second invocation formAcceptance Criteria
--columnsreads only the CSV header row, prints each column name on its own line to stdout, and exits 0--columns --verbose:id INTEGER,amount REAL,region TEXT--columnsis mutually exclusive with a query argument (prints usage error if both provided)--delimiterand--tsvflags--help, README.md Flags table, anddocs/sql-pipe.1.scdCloses #85