19 lines
1.1 KiB
Markdown
19 lines
1.1 KiB
Markdown
|
|
# 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
|
||
|
|
|
||
|
|
- [x] 1. Read `src/cli/report.ts` and identify where output is currently rendered.
|
||
|
|
- [x] 2. Define a `ReportJson` type in `src/cli/report-types.ts` matching the existing table columns.
|
||
|
|
- [~] 3. Add `--json` flag parsing to `src/cli/report.ts` and thread it through to the renderer.
|
||
|
|
- [x] 3a. Register the flag with the arg parser.
|
||
|
|
- [ ] 3b. Branch on the flag in `renderReport()` to call a new `renderJson()` helper.
|
||
|
|
- [ ] 4. Implement `renderJson()` that prints `JSON.stringify(data, null, 2)` and exits 0.
|
||
|
|
- [ ] 5. Update `--help` text and `README.md` usage section to document `--json`.
|
||
|
|
- [ ] 6. Add a test in `test/cli/report.test.ts` covering `--json` output 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 `--json` is set? Assuming yes; will confirm with user before step 4.
|