fix: add --json flag to "service-key" subcommand #3717
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.
The "cf service-key" command outputs JSON, apart from a standard header which most CF commands print out. As a result, it's very common to see code like:
This removes 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 woudld 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 supress warnings too (unless there an error). In practice the endpoints in question do not produce warnings, so it makes no practical difference.
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
We must be able to understand the design of your change from this description.
Keep in mind that the maintainer reviewing this PR may not be familiar with or
have worked with the code here recently, so please walk us through the concepts.
Why Is This PR Valuable?
What benefits will be realized by the code change? What users would want this change? What user need is this change addressing?
Applicable Issues
List any applicable GitHub Issues here
How Urgent Is The Change?
Is the change urgent? If so, explain why it is time-sensitive.
Other Relevant Parties
Who else is affected by the change?