Add --json to read-only commands (pr checks/files/commits/diff, secret/variable list) #112
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Task
Add
--jsonoutput to the read-only commands automation reaches for, routing the already-typed structs throughoutput::print_jsonexactly aspr view/issue viewdo:fj pr checks(combined_status: state, total_count, per-checkstatuses[]) — the canonical CI-gating query.fj pr files(status, filename, additions, deletions).fj pr commits(sha, subject, author).fj pr diff— emit{ "diff": "<text>" }(or document it as intentionally text-only and reject the flag explicitly).fj secret listandfj variable list— emit[{name, updated_at, ...}]so config can be diffed.Add a test asserting every
view/inspect/listsubcommand either accepts--jsonor is explicitly allow-listed as text-only, so the surface cannot silently regress.Source:
rasterstate/fj#109.Priority
p1.
fj pr checks --json | jq '.state'is the merge-gate / agent "is this PR green?" query;pr files --jsonbacks path-scoped policy;secret/variable list --jsonback config diffing. These are the surfaces automation scripts first, and--json-fields(a global flag) is meaningless on them today because no JSON exists to project. High scripting-reliability and gh-parity value.Reason
Each handler already builds structured data in memory and then flattens it to a table/text with no JSON branch (
src/cli/pr_inspect.rs,src/cli/workflow_secret.rs,src/cli/workflow_variable.rs). The inconsistency is also internal and trap-like:pr view/issue viewaccept--json, so a scripter assumes the rest ofprdoes, builds a wrapper, and hitserror: unexpected argument '--json'at runtime.ghreturns JSON for all of these.Acceptance
fj pr checks --jsonemits the combined-status struct (state, total_count, statuses).fj pr files --jsonandfj pr commits --jsonemit the per-file / per-commit arrays.fj pr diff --jsoneither returns{ "diff": "..." }or rejects with a clear "text-only" message (decision recorded in the help text).fj secret list --jsonandfj variable list --jsonemit name/updated_at arrays.--json-fieldsprojection works against each new JSON output (it flows throughprint_json).--jsonor is allow-listed text-only.cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings,cargo test --allpass.Dependencies
None. API responses are already typed; this is surfacing them through the existing
print_jsonpath. Can be split per-command if sized down, butpr checksandsecret/variable listare the highest-value first cuts.Size
M
--jsonoutput #109