feat(bugs): add --format json to bugs show and bugs close#279
Merged
Conversation
Triage agents repeatedly grep stdout for fields like the closed-via PR number and bug metadata (file path, security flag, blame). Only `bugs list` accepted `--format json`; `show` and `close` forced text-parsing. Add `--format <table|json>` (default `table`) to both subcommands: - `bugs show <id> --format json` — emits the full Bug payload - `bugs close <id> --state <s> --format json` — emits the resulting BugReview, suppressing the human "✓ Bug closed as: …" banner so stdout is pure JSON `is_silent` extended to suppress auto-update notices on the new JSON paths, matching how `bugs list --format json` already works. The table-view body of `Show` is unchanged; extracted into a `render_bug_show` helper to keep the handler match arm focused on the format dispatch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1a13d1a to
93eaf2d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Triage agents repeatedly grep stdout for fields that are already in the JSON payload — bug metadata (file path, security flag, blame, summary) for
show, and the resultingBugReviewforclose. Onlybugs listaccepted--format json;showandcloseforced text-parsing.Add
--format <table|json>(defaulttable) to both subcommands:bugs show <id> --format json— emits the fullBugpayload (id, title, summary, filePath, introducedIn, review, linkedIssues, …)bugs close <id> --state <s> --format json— emits the resultingBugReview, suppressing the human-friendly "✓ Bug closed as: …" banner so stdout is pure JSONis_silentextended to suppress auto-update notices on the new JSON paths, matching howbugs list --format jsonalready works.The table-view body of
Showis unchanged; extracted into arender_bug_showhelper so the handler match arm just dispatches on format.Testing
Automated, run locally and passing:
cargo test— full suite green. New clap-parse tests insrc/lib.rs:silent_when_bugs_show_json—bugs show … --format jsontriggers the silent-output pathsilent_when_bugs_close_json— same for closenot_silent_for_bugs_show/not_silent_for_bugs_closestill pass (default format istable)cargo clippy -- -D warnings— cleancargo fmt --check— cleancargo xtask check— clean (HELP.md regenerated for the two new flags)Manual end-to-end against live API:
bugs show bug_5d237de8-… --format json→ valid JSON, all expected fields present:bugs show bug_5d237de8-…(default) → unchanged: ID/Title/File/Created/Security/Introduced/Issue rows + markdown summarybugs close bug_e79362bd-… --state dismissed --dismissal-reason not-a-bug --format json(idempotent re-close on an already-dismissed bug) → emits theBugReviewJSON only, no✓ Bug closed as:banner.head -1of stdout is just{.bugs show bug_does_not_exist --format json→Error: Failed to fetch bug details(still propagates errors via stderr; stdout stays empty)bugs closewithout--notesoverwrites any existingreview.noteswithnull— the API client sendsnotes: Nonewhich the backend treats as "set to null" rather than "leave unchanged". Caught when re-closing an already-dismissed bug for this PR's smoke test; the original notes were restored manually. Not introduced by this PR but tagged for follow-up.🤖 Generated with Claude Code