CLI: add metadata-only JSON output to environment comparisons
Maintainers usually reply within 1 day
@MayurK-cmd is already working on this.
Since Oct 7, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
Research direction
Read EnvCommand::Diff and env_diff() in crates/cli/src/main.rs, then inspect App::env_diff() and DiffStatus in crates/cli/src/commands.rs to reuse the existing comparison states. Use the sotto env ls --json serializer and parser tests as a pattern. Add the metadata-only JSON option and focused tests; done means all four statuses, empty output, escaped/non-ASCII names, and absence of value fields are covered, with help updated and focused CLI tests passing.
Written by the indexing model from the issue text.
Description
Need
Scripts comparing environment configuration currently have to parse the presentation markers from sotto env diff: =, !, < and >, with explanatory text around names. Add an opt-in JSON form for inspecting which names are equal, different, or present on only one side.
This should expose comparison metadata only. The existing human-readable command and its explicit --reveal behaviour remain available.
Current implementation
Source-reviewed on current main at 38fab371340be0aff7970b0f5f9b1282fabc21f7 in a clean macOS arm64 checkout:
EnvCommand::Diffandenv_diff()offerleft,rightand--reveal, but no JSON flag. They render one marker line per name and a summary on stderr.App::env_diff()andDiffStatusalready calculate a sorted union with four explicit comparison states.sotto env ls --jsonand its serializer/parser tests provide a nearby implementation pattern.
This is a feature request based on the existing interface, not a runtime defect. No live environment comparison was performed. #288 documented the current text markers; it did not add machine-readable output.
Output contract
Use sotto env diff dev staging --json to emit an array like this (synthetic names):
[
{"name":"API_URL","status":"differs"},
{"name":"LOG_LEVEL","status":"equal"},
{"name":"STAGING_FLAG","status":"only_right"}
]
The four status strings are equal, differs, only_left, and only_right. Left and right refer to the positional arguments.
Acceptance criteria
- Add
--json, with stdout containing just a JSON array sorted by name; two empty environments produce[]. - Emit only
nameandstatus. Do not serializeDiffEntry's secret value fields into this output. - Make
--jsonand--revealexplicitly conflict in argument parsing so the metadata-only contract is unambiguous. - Preserve existing text output, error behaviour and exit status when
--jsonis absent; differences themselves should not acquire a new exit-code policy. - Add parser/serialization tests for all four statuses, empty output, escaped/non-ASCII names, and absence of value fields. Reuse the existing comparison logic rather than implementing a second diff.
- Add the JSON example and status meanings to command help, and run the focused CLI tests.
This is a bounded CLI output feature. No server or cryptographic change is needed. Follow CONTRIBUTING.md, including DCO sign-off (git commit -s).
- Dominant language
- Rust
- Stars
- 31
- Forks
- 42
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 142
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsotto/sotto
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
good first issue help wanted test-coverage
Difficulty 2/5 3-5 days Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
software-mansion/pathfinder#3620 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug priority: low
Difficulty 1/5 Under an hour Newbie friendliness 90/100
storytold/wordcraft#6211 · 1 comment ·
Maintainers usually reply within 2 days
-
backlog multiple issues priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
storytold/pdfcraft#6911 · 2 comments ·
Maintainers usually reply within 2 days
-
DGNIMPORT: "The DGN model has nothing that can be imported" when the first element streams are emptyOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
HakanSeven12/OpenCADStudio#2820 · 1 comment ·
Maintainers usually reply within 1 day