Color returns a color for the given string.
(s string)
| 50 | |
| 51 | // Color returns a color for the given string. |
| 52 | func Color(s string) termenv.Color { |
| 53 | colorOnce.Do(func() { |
| 54 | color = termenv.NewOutput(os.Stdout).EnvColorProfile() |
| 55 | |
| 56 | if flag.Lookup("test.v") != nil { |
| 57 | // Use a consistent colorless profile in tests so that results |
| 58 | // are deterministic. |
| 59 | color = termenv.Ascii |
| 60 | } |
| 61 | }) |
| 62 | return color.Color(s) |
| 63 | } |
| 64 | |
| 65 | func isTerm() bool { |
| 66 | return color != termenv.Ascii |