-
Notifications
You must be signed in to change notification settings - Fork 885
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
Disabling color through environment variables #598
Conversation
…bles. - NO_COLOR: https://no-color.org/ - CLICOLOR,CLICOLOR_FORCE: https://bixense.com/clicolors/ ( [logrus built-in](https://github.com/sirupsen/logrus/blob/6699a89a232f3db797f2e280639854bbc4b89725/text_formatter.go#L46) )
I have seen PR #562 but it changes rather important defaults while
this patch disables coloring only if user has set some environment
variable.
Without those env vars everything stays the same.
I could have added a command line param but I have opt-ed for some
standard way.
If this really isn't acceptable I might go that route though.
…On 08.07.2020 21:21, nils måsén wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In cmd/root.go
+ log.SetFormatter(&log.TextFormatter{
+ EnvironmentOverrideColors: true,
+ })
Probably not a good idea, see #562
|
Yeah, I noticed, so I removed the comment. I don't think there are any issues with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! While I really like the feature you've added, I'd kindly like to ask you to implement it the same way as all other flags and env vars in watchtower, namely in https://github.com/containrrr/watchtower/blob/master/internal/flags/flags.go using viper and cobra. I'd also like to ask you to document this feature in https://github.com/containrrr/watchtower/blob/master/docs/arguments.md
Thanks again. 🙇
cmd/root.go
Outdated
@@ -61,6 +61,18 @@ func Execute() { | |||
func PreRun(cmd *cobra.Command, args []string) { | |||
f := cmd.PersistentFlags() | |||
|
|||
// https://no-color.org/ | |||
if _, enabled := os.LookupEnv("NO_COLOR"); enabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be implemented the same way as all other flags and env vars.
@all-contributors add @bugficks for code |
Thank you for your contribution! 🙇 |
I've put up a pull request to add @bugficks! 🎉 |
This patch adds support for disabling color through environment variables.