Skip to content

feat: users can simply set --yaml, instead of --output yaml#668

Merged
mcncl merged 2 commits intomainfrom
SUP-6285/output_format_flags
Feb 26, 2026
Merged

feat: users can simply set --yaml, instead of --output yaml#668
mcncl merged 2 commits intomainfrom
SUP-6285/output_format_flags

Conversation

@mcncl
Copy link
Contributor

@mcncl mcncl commented Feb 26, 2026

Description

We can use the AfterApply() hook in Kong to evaluate the use of output flags, which can be --output <value>, --json, --text or --yaml. Using xor allows us to ensure folks can't set --yaml --json. However, --output yaml --text will see that --text "wins".

Changes

  • moves output flags logic to a new struct in pkg/output/flags.go
    • sets xor so that only one output option can be used
    • added a comment so folks know how to use
  • uses an AfterApply() hook to assess the boolean states when output flags are set
  • persists json default
  • updates all commands with an Output option to instead use the new flags in the output package

Testing

  • Tests have run locally (with go test ./...)
  • Code is formatted (with go fmt ./...)

We can use the `AfterApply()` hook in Kong to evaluate the use of output flags, which can be `--output <value>`, `--json`, `--text` or `--yaml`. Using `xor` allows us to ensure folks can't set `--yaml --json`. However, `--output yaml --text` will see that `--text` "wins".
@mcncl mcncl requested a review from a team as a code owner February 26, 2026 03:53
@mcncl mcncl merged commit 5467aaf into main Feb 26, 2026
1 check passed
@mcncl mcncl deleted the SUP-6285/output_format_flags branch February 26, 2026 05:36
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