feat(pr): add --json output to pr search (FJ-1) #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/pr-search-json"
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?
What
Adds a
--jsonflag tofj pr search(FJ-1) that emits the matched pull requests as a JSON array, one record per PR, suitable for piping into nu / jq.Why
fj pr searchpreviously only produced human-readable output, so callers needing machine-readable data had to parse that fragile format or bypassfjentirely and hit the Forgejo REST API directly (re-implementing auth, field selection, and error handling). That is the Tooling Gap Discipline anti-pattern flagged in FJ-1, found while buildingclaude-bot/actions/forgejo-ci-fix.yml.How
Filters still flow through
issue_list_issues, which honors--repo,--state,--labels,--creator, and--assignee. That endpoint only returnsIssuerecords (no head/base/sha), so each matched PR is fetched viarepo_get_pull_requestto fill inhead_sha,head_ref, andbase_ref. An empty result prints[]instead of erroring.Field names mirror the documented schema:
number,title,state,head_sha,head_ref,base_ref,author,html_url,created_at,updated_at,draft,labels. Timestamps are normalized to UTC RFC 3339 (trailingZ) so output is deterministic regardless of the server's timezone;stateserializes to"open"/"closed".Acceptance criteria
fj pr search --state open --jsonreturns a JSON array.number,head_sha,head_ref,base_ref,author,html_url,updated_atat minimum.[], not an error.--repo,--state,--labels,--creator,--assigneefilters.Testing
Verified against
longjacksonle/claude-fix-sandbox(the repo referenced in the issue): populated output matches the documented schema,--state openon the empty target repo returns[], and each filter (--state,--creator,--assignee,--labels,--repo) runs without error.cargo build,cargo clippy(no new warnings), andcargo testall pass.Upstream
fjlives at https://codeberg.org/forgejo-contrib/forgejo-cli. This is a fork-local change; mirroring upstream is still a follow-up per FJ-1.Closes FJ-1.
🤖 Generated with Claude Code