Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint/rpt: Handle no-color ttys #1213

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Conversation

charlieegan3
Copy link
Member

This fixes #1211 by supporting the NO_COLOR environment variable and checking if the output is a tty before using color.

The color.NoColor global is used as described here: https://github.com/fatih/color?tab=readme-ov-file#disableenable-color

@charlieegan3 charlieegan3 force-pushed the no-color branch 2 times, most recently from 7fac2f6 to 2523f6e Compare October 21, 2024 12:30
Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks!

// if there is no support for color, then we show the level in addition
// so that the level of the violation is still clear
if color.NoColor {
table.Append([]string{yellow("Level:"), violation.Level})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a little odd to use yellow() here, doesn't it? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 hmm indeed!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated this now

This fixes StyraInc#1211 by supporting
the NO_COLOR environment variable and checking if the output is a tty
before using color.

The color.NoColor global is used as described here: https://github.com/fatih/color?tab=readme-ov-file#disableenable-color

Signed-off-by: Charlie Egan <charlie@styra.com>
Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@anderseknert anderseknert merged commit 234e36b into StyraInc:main Oct 21, 2024
4 checks passed
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.

lint: Suggestion - issues with error levels in output
3 participants