Package software.amazon.smithy.cli
Enum AnsiColorFormatter
- java.lang.Object
-
- java.lang.Enum<AnsiColorFormatter>
-
- software.amazon.smithy.cli.AnsiColorFormatter
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AnsiColorFormatter>
,ColorFormatter
public enum AnsiColorFormatter extends java.lang.Enum<AnsiColorFormatter> implements ColorFormatter
Styles text using ANSI color codes.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTO
Writes using ANSI colors if it detects that the environment supports color.FORCE_COLOR
Writes with ANSI colors.NO_COLOR
Does not write any color.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AnsiColorFormatter
detect()
Detects if ANSI colors are supported and returns the appropriate Ansi enum variant.static AnsiColorFormatter
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static AnsiColorFormatter[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface software.amazon.smithy.cli.ColorFormatter
endStyle, isColorEnabled, println, startStyle, style, style
-
-
-
-
Enum Constant Detail
-
NO_COLOR
public static final AnsiColorFormatter NO_COLOR
Does not write any color.
-
FORCE_COLOR
public static final AnsiColorFormatter FORCE_COLOR
Writes with ANSI colors.
-
AUTO
public static final AnsiColorFormatter AUTO
Writes using ANSI colors if it detects that the environment supports color.
-
-
Method Detail
-
values
public static AnsiColorFormatter[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (AnsiColorFormatter c : AnsiColorFormatter.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static AnsiColorFormatter valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
detect
public static AnsiColorFormatter detect()
Detects if ANSI colors are supported and returns the appropriate Ansi enum variant.This method differs from using the
AUTO
variant directly because it will detect any changes to the environment that might enable or disable colors.- Returns:
- Returns the detected ANSI color enum variant.
-
-