Problem
Some read-side commands (datalex validate, datalex info, datalex diff) support --format json, but the flag isn't uniform — some commands only emit human output, and the JSON shapes vary across commands that do. This makes it harder to script DataLex into CI and other tools.
Goal
Every read-side datalex subcommand should accept --format {human,json} (default human). When --format json is passed:
- Output is a single top-level JSON document on stdout.
- No log/warning/banner text on stdout; route those to stderr.
- The schema is stable and documented — document each command's JSON shape in
docs/cli.md.
Suggested approach
- Inventory the read commands (search
packages/cli/src/datalex_cli/ for add_parser / subparsers).
- Factor a tiny helper —
emit_result(result: Any, *, format: str) — that pretty-prints or JSON-dumps.
- Flip each command over to the helper.
- Add one test per command that asserts
--format json output parses and includes expected keys.
Acceptance criteria
datalex validate --format json → diagnostics array.
datalex info --format json → project summary.
datalex diff --format json → structured diff (reuse diff.py's internal dataclasses).
datalex packages list --format json → resolved-packages list.
- No stdout contamination when
--format json is active.
Why this is a good first issue
Small surface per command, easy to verify, no core engine changes. Gives you a tour of the CLI layer and forces clean separation of presentation from logic.
Problem
Some read-side commands (
datalex validate,datalex info,datalex diff) support--format json, but the flag isn't uniform — some commands only emit human output, and the JSON shapes vary across commands that do. This makes it harder to script DataLex into CI and other tools.Goal
Every read-side
datalexsubcommand should accept--format {human,json}(defaulthuman). When--format jsonis passed:docs/cli.md.Suggested approach
packages/cli/src/datalex_cli/foradd_parser/ subparsers).emit_result(result: Any, *, format: str)— that pretty-prints or JSON-dumps.--format jsonoutput parses and includes expected keys.Acceptance criteria
datalex validate --format json→ diagnostics array.datalex info --format json→ project summary.datalex diff --format json→ structured diff (reusediff.py's internal dataclasses).datalex packages list --format json→ resolved-packages list.--format jsonis active.Why this is a good first issue
Small surface per command, easy to verify, no core engine changes. Gives you a tour of the CLI layer and forces clean separation of presentation from logic.