Add --json / -j flag to all stats subcommands#1719
Merged
Conversation
Accept --json (-j) as an alias for --format=json on stats aggregate, historical, usage, realtime, domain-inspector and origin-inspector, matching the flag convention used by the rest of the CLI. Since "json" was the only accepted value for --format on all of these commands, the old flag still works but is now hidden in favor of the shorter form. Also fix a timing bug where the deferred update-check notice was not suppressed in JSON mode because data.Flags.JSON was captured before Exec() had a chance to set it.
rcaril
reviewed
Apr 9, 2026
rcaril
approved these changes
Apr 9, 2026
Member
rcaril
left a comment
There was a problem hiding this comment.
One query, otherwise looks good!
jedisct1
added a commit
to dip-proto/fastly-cli
that referenced
this pull request
Apr 14, 2026
* main: build(deps): bump the go-dependencies group with 5 updates (fastly#1726) release 14.3.1 (fastly#1725) Restore permission for trusted publishing (fastly#1724) Release 14.3.0 (fastly#1723) [CDTOOL-1193] Support for Logging Endpoint Errors (fastly#1721) chore(deps): bump go-fastly to 14.2.0 (fastly#1722) Add --json / -j flag to all stats subcommands (fastly#1719) build(deps): bump the go-dependencies group with 4 updates (fastly#1720) Add "auth revoke" subcommand for token revocation (fastly#1717) Restrict GitHub Actions workflow permissions to least privilege (fastly#1718)
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.
Change summary
All stats subcommands (
aggregate,historical,usage,realtime,domain-inspector,origin-inspector) now accept--json/-jas a shorthand for--format=json. Since "json" was the only value--formatever accepted on any of these commands, the old flag is kept for backwards compatibility but hidden from help output.This also fixes a timing bug where the CLI's deferred update-check notice could leak into stdout when a stats command ran with
--format=json.All Submissions:
New Feature Submissions:
Changes to Core Features:
User Impact
Users can now pass
--jsonor-jto any stats subcommand instead of the longer--format=json.This matches the flag style already used by the rest of the CLI.
And the update-check notice no longer bleeds into JSON output for stats commands.
Are there any considerations that need to be addressed for release?
None. The old
--format=jsonflag still works; it is simply hidden from help text.