Support the NO_COLOR env variable to suppres any colored output.#1594
Support the NO_COLOR env variable to suppres any colored output.#1594CyrusNajmabadi merged 9 commits intomasterfrom
Conversation
|
|
||
| opts := backend.DisplayOptions{ | ||
| Color: cmdutil.GetGlobalColorization(), | ||
| } |
There was a problem hiding this comment.
For command that do not support a --color flag, this is the pattern to use. The color picked here will be "Never" if NO_COLOR is set in the environment. Or 'Always' otherwise. In the future we can consider if these command shoudl support --color as well. But i didn't want to have to add that here.
|
|
||
| msg := fmt.Sprintf("%sThe currently running update for '%s' has been canceled!%s", colors.SpecAttention, s.Name(), | ||
| colors.Reset) | ||
| fmt.Println(colors.ColorizeText(msg)) |
There was a problem hiding this comment.
no one should call colors.ColorizeText now. Only the very lowest level (that is calling into 'lorely') now does this.
There was a problem hiding this comment.
Is it possible to stop exporting it? A brief look at the code makes me think we may be able to do but I am not sure.
There was a problem hiding this comment.
Yup. I've stopped exporting it.
| Color: cmdutil.GetGlobalColorization(), | ||
| } | ||
|
|
||
| s, err := requireStack(stack, false, opts) |
There was a problem hiding this comment.
Many interactive functions now take in opts so they can decide if they should colorize or not.
|
Related issues this may close |
|
Would it be possible as part of this to make the --color flag global across all commands? |
Yes. I can look into that. |
|
Making this a global flag worked, and def cleaned things up. |
|
Note: at this point... passing the variable around serves almost no purpose. It's effectively just a process-wide global that is set right at startup... I'm going to keep as is. but we could literally just remove all usages of passing things around... |
|
|
||
| // GetGlobalColorization gets the global setting for how things should be colored. | ||
| // This is helpful for the parts of our stack that do not take a DisplayOptions struct. | ||
| func GetGlobalColorization() colors.Colorization { |
There was a problem hiding this comment.
I would have assumed this would have to check the global c value you in the root pulumi command? Is that done some other place?
There was a problem hiding this comment.
it's somewhat the reverse. the pulumi command just goes and sets this, so that it's available for anyone to go find if they need.
That's what i meant in my comment about us not needing to really pass along any 'color' option anymore. There is always just a well known place it can be found.
No description provided.