shouldDisableAnsi checks whether ANSI escape sequences should be explicitly suppressed via environment variables. The hook runs as a separate subprocess where the normal PersistentPreRunE (which calls formatter.SetANSIMode) is skipped, so we check NO_COLOR and COMPOSE_ANSI directly. TTY detection i
()
| 59 | // PrintNextSteps (which itself emits bold ANSI unconditionally). The hook |
| 60 | // subprocess cannot reliably detect whether the parent's output is a terminal. |
| 61 | func shouldDisableAnsi() bool { |
| 62 | if noColor, ok := os.LookupEnv("NO_COLOR"); ok && noColor != "" { |
| 63 | return true |
| 64 | } |
| 65 | if v, ok := os.LookupEnv("COMPOSE_ANSI"); ok && v == formatter.Never { |
| 66 | return true |
| 67 | } |
| 68 | return false |
| 69 | } |
| 70 | |
| 71 | type hookHint struct { |
| 72 | template func(appID string) string |