feat: add --json flag to "service-key" subcommand (main) #3693
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.
Thank you for contributing to the CF CLI! Please read the following:
If your contribution falls under a company CLA but your membership is not public, expect delays while we confirm.
Note: Please create separate PR for every branch (main and v8) as needed.
Description of the Change
It's very common to see code like:
This removed the header from the output leaving just JSON. Search GitHub and you'll see pages of hits.
Rather than forcing script users to chop of the header, risking issues with errors in pipes, etc... It would be better just to print the correct output in the first place. This commit: adds a "--json" flag which outputs JSON only. It follows the convention of "--guid" to suppress warnings too (unless there an error). In practice the endpoints in question do not produce warnings, so it makes no practical difference.
Why Is This PR Valuable?
Lots of folks are having to work around the lack of this feature.
Applicable Issues
A draft and stale PR that attempts to add this for some other commands: #3249
How Urgent Is The Change?
No rush
Other Relevant Parties
Who else is affected by the change?