(flagNoColor, flagForceColor bool)
| 142 | } |
| 143 | |
| 144 | func setColorEnabled(flagNoColor, flagForceColor bool) bool { |
| 145 | if flagNoColor || anyEnvSet([]string{"EC_NO_COLOR", "EC_NO_COLOUR", "NO_COLOR", "NO_COLOUR"}) { |
| 146 | // Force no color |
| 147 | return false |
| 148 | } |
| 149 | if flagForceColor || anyEnvSet([]string{"EC_FORCE_COLOR", "EC_FORCE_COLOUR", "FORCE_COLOR", "FORCE_COLOUR"}) { |
| 150 | // Force color |
| 151 | return true |
| 152 | } |
| 153 | // Use color if we're in a terminal that can presumably display it |
| 154 | return isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) |
| 155 | } |
| 156 | |
| 157 | func anyEnvSet(varNames []string) bool { |
| 158 | for _, varName := range varNames { |
no test coverage detected