enhancement: Add --color
flag to cerbos compile
#754
Merged
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.
Description
Fixes #752 (the color level is now set for
pterm
as well as thecolor
library, so--no-color
turns off all coloring in the tree output)Fixes #753
This PR introduces a complimentary
--color
flag in addition to the existing--no-color
.With the default of
--color=auto
, the output color level is detected from the environment by checking if stdout is a TTY and looking for various environment variables (see https://pkg.go.dev/github.com/jwalton/go-supportscolor for details).Otherwise, the output color level is set to:
--no-color
,--color=false
, or--color=never
;--color
,--color=true
, or--color=always
;--color=256
; and--color=16m
,--color=full
, or--color=truecolor
This is basically a translation of
go-supportscolor
's "sniff flags" functionality to make it compatible with Kong (which barfs on unknown flags, so we need to explicitly define them).