Skip to content

Conversation

@blgm
Copy link
Member

@blgm blgm commented Jan 26, 2026

Thank you for contributing to the CF CLI! Please read the following:

  • Please make sure you have implemented changes in line with the contributing guidelines
  • We're not allowed to accept any PRs without a signed CLA, no matter how small.
    If your contribution falls under a company CLA but your membership is not public, expect delays while we confirm.
  • All new code requires tests to protect against regressions.
  • Contributions must be made against the appropriate branch. See the contributing guidelines
  • Contributions must conform to our style guide. Please reach out to us if you have questions.

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:

cf service-key "$SERVICE_INSTANCE_NAME" $KEY_NAME | tail -n +2

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?

It's very common to see code like:
```
cf service-key "$SERVICE_INSTANCE_NAME" $KEY_NAME | tail -n +2
```
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 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.
@blgm blgm changed the title feat: add --json flag to "service-key" subcommand feat: add --json flag to "service-key" subcommand (main) Jan 26, 2026
@blgm blgm marked this pull request as ready for review January 26, 2026 22:59
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.

1 participant