Skip to content

feat: add --json flag as shorthand for --output json#656

Merged
apucacao merged 3 commits intomainfrom
ag/json-flag
Mar 11, 2026
Merged

feat: add --json flag as shorthand for --output json#656
apucacao merged 3 commits intomainfrom
ag/json-flag

Conversation

@apucacao
Copy link
Contributor

@apucacao apucacao commented Mar 11, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

N/A

Describe the solution you've provided

AI agents commonly try --json to get machine-readable output (it's the convention in gh, kubectl, aws, etc.). We already had --output json but that's not discoverable if you don't know to look for it — you just get unknown flag: --json.

This adds --json as a persistent flag on all commands that sets the output format to JSON.

Describe alternatives you've considered

Documenting --output json better. But since --json is 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 --json flag (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 --json takes precedence over the --output setting, 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.

apucacao and others added 2 commits March 11, 2026 15:01
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>
@apucacao apucacao mentioned this pull request Mar 11, 2026
3 tasks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@apucacao apucacao marked this pull request as ready for review March 11, 2026 19:20
@apucacao apucacao requested a review from a team March 11, 2026 19:46
@apucacao apucacao merged commit 65d1bc3 into main Mar 11, 2026
15 checks passed
@apucacao apucacao deleted the ag/json-flag branch March 11, 2026 19:49
apucacao added a commit that referenced this pull request Mar 11, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants