Skip to content

Add --json / -j flag to all stats subcommands#1719

Merged
jedisct1 merged 5 commits into
mainfrom
fdenis/json
Apr 9, 2026
Merged

Add --json / -j flag to all stats subcommands#1719
jedisct1 merged 5 commits into
mainfrom
fdenis/json

Conversation

@jedisct1
Copy link
Copy Markdown
Contributor

@jedisct1 jedisct1 commented Apr 7, 2026

Change summary

All stats subcommands (aggregate, historical, usage, realtime, domain-inspector, origin-inspector) now accept --json / -j as a shorthand for --format=json. Since "json" was the only value --format ever 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:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

Users can now pass --json or -j to 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=json flag still works; it is simply hidden from help text.

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.
@jedisct1 jedisct1 requested a review from a team as a code owner April 7, 2026 14:43
@jedisct1 jedisct1 requested a review from rcaril April 7, 2026 14:43
Comment thread pkg/commands/stats/domain_inspector.go
Copy link
Copy Markdown
Member

@rcaril rcaril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One query, otherwise looks good!

@jedisct1 jedisct1 merged commit 50c4899 into main Apr 9, 2026
13 checks passed
@jedisct1 jedisct1 deleted the fdenis/json branch April 9, 2026 15:37
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)
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