Summary
Introduce src/format.zig as the canonical module for format types and output dispatch, and decompose the 2308-line main.zig god file into focused modules.
Motivation
main.zig mixes CLI parsing, business logic, SQL DDL, loading orchestration, and output dispatch. Adding a new format currently requires touching 6+ places in main.zig. The goal is to reduce that to: create one new file + register in one place.
Phases
- Phase 1 (this issue): Create
src/format.zig with InputFormat, OutputFormat, ColumnType, LoadOpts, WriteOpts, and OutputWriter. Migrate execQuery to use OutputWriter.
- Phase 2: Reorganize into
src/formats/ and src/modes/ subdirectories.
- Phase 3: Consolidate
sqlite.zig helpers (eliminate duplicates with main.zig).
- Phase 4: Extract
loader.zig to unify the 4 duplicated CSV-loading loops.
- Phase 5: Move integration tests out of
build.zig.
Summary
Introduce
src/format.zigas the canonical module for format types and output dispatch, and decompose the 2308-linemain.ziggod file into focused modules.Motivation
main.zigmixes CLI parsing, business logic, SQL DDL, loading orchestration, and output dispatch. Adding a new format currently requires touching 6+ places inmain.zig. The goal is to reduce that to: create one new file + register in one place.Phases
src/format.zigwithInputFormat,OutputFormat,ColumnType,LoadOpts,WriteOpts, andOutputWriter. MigrateexecQueryto useOutputWriter.src/formats/andsrc/modes/subdirectories.sqlite.zighelpers (eliminate duplicates withmain.zig).loader.zigto unify the 4 duplicated CSV-loading loops.build.zig.