1.1 KiB
1.1 KiB
Plan: Add --json output mode to the report CLI
Add a --json flag to the existing report command so it can emit machine-readable output in addition to the current human-readable table. Must not change default behavior.
Tasks
- 1. Read
src/cli/report.tsand identify where output is currently rendered. - 2. Define a
ReportJsontype insrc/cli/report-types.tsmatching the existing table columns. - [~] 3. Add
--jsonflag parsing tosrc/cli/report.tsand thread it through to the renderer.- 3a. Register the flag with the arg parser.
- 3b. Branch on the flag in
renderReport()to call a newrenderJson()helper.
- 4. Implement
renderJson()that printsJSON.stringify(data, null, 2)and exits 0. - 5. Update
--helptext andREADME.mdusage section to document--json. - 6. Add a test in
test/cli/report.test.tscovering--jsonoutput shape.
Notes
- Keep default (non-
--json) output byte-identical to current behavior — existing snapshot tests must still pass. - Open question: should errors also be JSON when
--jsonis set? Assuming yes; will confirm with user before step 4.