()
| 112 | } |
| 113 | |
| 114 | func shouldUseColors() bool { |
| 115 | useColors := ForceColors || iostream.IsOutputTerminal() |
| 116 | |
| 117 | if EnvironmentOverrideColors { |
| 118 | force, ok := os.LookupEnv("CLICOLOR_FORCE") |
| 119 | |
| 120 | switch { |
| 121 | case ok && force != "0": |
| 122 | useColors = true |
| 123 | case ok && force == "0": |
| 124 | useColors = false |
| 125 | case os.Getenv("CLICOLOR") == "0": |
| 126 | useColors = false |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | return useColors && !DisableColors |
| 131 | } |