feat: add --json flag as shorthand for --output json#656
Merged
Conversation
Adds a persistent --json boolean flag to all commands, matching the convention used by gh, kubectl, and other agent-friendly CLIs. Implements GetOutputKind(cmd) helper in cliflags that checks --json before falling back to --output, avoiding PersistentPreRun override issues with child commands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zmdavis
approved these changes
Mar 11, 2026
apucacao
added a commit
that referenced
this pull request
Mar 11, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Requirements
Related issues
N/A
Describe the solution you've provided
AI agents commonly try
--jsonto get machine-readable output (it's the convention ingh,kubectl,aws, etc.). We already had--output jsonbut that's not discoverable if you don't know to look for it — you just getunknown flag: --json.This adds
--jsonas a persistent flag on all commands that sets the output format to JSON.Describe alternatives you've considered
Documenting
--output jsonbetter. But since--jsonis a widely established convention, adding the alias is lower friction than expecting agents and users to discover--output.Additional context
N/A
Note
Low Risk
Low risk: adds a new persistent flag and routes existing output/validation logic through a small helper to prefer JSON when requested.
Overview
Adds a new persistent
--jsonflag (documented in help output) that acts as a shorthand for--output json.Introduces
cliflags.GetOutputKind(cmd)and updates command implementations and validators to use it so--jsontakes precedence over the--outputsetting, plus adds a root-level test asserting raw JSON output for--json.Written by Cursor Bugbot for commit cbfa50b. This will update automatically on new commits. Configure here.