private static boolean isAnsiEnabled() {
        if (EnvironmentVariable.FORCE_COLOR.isSet()) {
            return true;
        }

        // Disable colors if NO_COLOR is set to anything.
        if (EnvironmentVariable.NO_COLOR.isSet()) {
            return false;
        }

        String term = EnvironmentVariable.TERM.get();

        // If term is set to "dumb", then don't use colors.
        if (Objects.equals(term, "dumb")) {
            return false;
        }

        // If TERM isn't set at all and Windows is detected, then don't use colors.
        if (term == null && System.getProperty("os.name").contains("win")) {
            return false;
        }

        // Disable colors if no console is associated.
        return System.console() != null;
    }
Detects if ANSI colors are supported and returns the appropriate Ansi enum variant.

<p>This method differs from using the {@link AnsiColorFormatter#AUTO} variant directly because it will
detect any changes to the environment that might enable or disable colors.

@return Returns the detected ANSI color enum variant.
smithy-cli/src/main/java/software/amazon/smithy/cli/AnsiColorFormatter.java