Add --json to read-only pr/secret/variable commands #118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/112-json-readonly"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
--jsonto the read-only commands automation reaches for, routing each handler's already-typed struct through the existingoutput::print_jsonpath thatpr view/issue viewuse. Closes the trap where a scripter assumes the rest ofpraccepts--json(becausepr viewdoes) and hitserror: unexpected argument '--json'at runtime.What's covered
fj pr checks --jsonemits the combined-status struct (state,total_count,statuses[]) — the merge-gate / "is this PR green?" query.fj pr files --jsonandfj pr commits --jsonemit the per-file / per-commit arrays.fj pr diff --jsonwraps the text as{ "diff": "..." }rather than rejecting the flag; the decision is recorded in the subcommand help.fj secret list --jsonandfj variable list --jsonemitname/created_at(ordata) arrays for config diffing.--json-fieldsprojection works against each new output, since they all flow throughprint_json.Implementation notes
The inspect subcommands moved from the shared
SimpleArgsto a newInspectArgsthat carries--json, so the mutating siblings (ready/close/reopen) keep a clean argument surface.secret listandvariable listshareSecretListArgs, so a single flag covers both. The sharedoutput::print_jsonhelper is reused untouched.Tests
view/list/ inspect leaf either accepts--jsonor is explicitly allow-listed as text-only, so the surface cannot silently regress. The handful of pre-existing local/config listings (auth list,alias list,config list,extension list,instances list,auth status) are allow-listed with reasons.--json-fieldsprojection over it (including dotted-path and array projection).Gates:
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings,cargo test --all(447 passing) all green.Fixes rasterstate/fj#112
The read-only inspect surface (pr diff/commits/files/checks, secret list, variable list) built structured data in memory and only ever flattened it to a table, so automation hit `error: unexpected argument '--json'` even though pr view / issue view accept it. Route each handler's already-typed struct through the existing output::print_json path so --json and the global --json-fields projection work uniformly. pr diff is text, so --json wraps it as `{ "diff": "..." }` rather than rejecting the flag; the decision is recorded in the subcommand help. A new regression test walks the clap tree and asserts every view/list/ inspect leaf either accepts --json or is explicitly allow-listed as text-only, so the surface cannot silently regress. Wiremock tests cover each new JSON path and its field projection. Fixes rasterstate/fj#112