Package nz.org.riskscape.picocli
Enum Class CommandLine.Help.Ansi
- All Implemented Interfaces:
Serializable,Comparable<CommandLine.Help.Ansi>,Constable
- Enclosing class:
- CommandLine.Help
Provides methods and inner classes to support using ANSI escape codes in usage help messages.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefines the interface for an ANSI escape sequence.static enumA set of pre-defined ANSI escape code styles and colors, and a set of convenience methods for parsing text with embedded markup style names, as well as convenience methods for converting styles to strings with embedded escape codes.classEncapsulates rich text with styles and colors.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionOnly emit ANSI escape codes if the platform supports it and system property"picocli.ansi"is not set to any value other than"true"(case insensitive).Forced OFF: never emit ANSI escape code regardless of the platform.Forced ON: always emit ANSI escape code regardless of the platform. -
Method Summary
Modifier and TypeMethodDescriptionapply(String plainText, List<CommandLine.Help.Ansi.IStyle> styles) Returns a new Text object where all the specified styles are applied to the full length of the specified plain text.booleanenabled()Returnstrueif ANSI escape codes should be emitted,falseotherwise.Returns a String where any markup like@|bg(red),white,underline some text|@is converted to ANSI escape codes if this Ansi is ON, or suppressed if this Ansi is OFF.Returns a new Text object for this Ansi mode, encapsulating the specified string which may contain markup like@|bg(red),white,underline some text|@.static CommandLine.Help.AnsivalueOf(boolean enabled) Returns Ansi.ON if the specifiedenabledflag is true, Ansi.OFF otherwise.static CommandLine.Help.AnsiReturns the enum constant of this class with the specified name.static CommandLine.Help.Ansi[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
AUTO
Only emit ANSI escape codes if the platform supports it and system property"picocli.ansi"is not set to any value other than"true"(case insensitive). -
ON
Forced ON: always emit ANSI escape code regardless of the platform. -
OFF
Forced OFF: never emit ANSI escape code regardless of the platform.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
enabled
public boolean enabled()Returnstrueif ANSI escape codes should be emitted,falseotherwise.- Returns:
- ON:
true, OFF:false, AUTO: if system property"picocli.ansi"has value"tty"(case-insensitive), then returntrueif eitherSystem.console() != nullor picocli guesses the application is running in a pseudo-terminal pty on a Linux emulator in Windows. If system property"picocli.ansi"has value"true"(case-sensitive) then returntrue. Otherwise use picocli's Heuristics for Enabling ANSI to determine whether the platform supports ANSI escape codes.
-
text
Returns a new Text object for this Ansi mode, encapsulating the specified string which may contain markup like
@|bg(red),white,underline some text|@.Calling
toString()on the returned Text will either include ANSI escape codes (if this Ansi mode is ON), or suppress ANSI escape codes (if this Ansi mode is OFF).Equivalent to
this.new Text(stringWithMarkup). -
string
Returns a String where any markup like
@|bg(red),white,underline some text|@is converted to ANSI escape codes if this Ansi is ON, or suppressed if this Ansi is OFF.Equivalent to
this.new Text(stringWithMarkup).toString(). -
valueOf
Returns Ansi.ON if the specifiedenabledflag is true, Ansi.OFF otherwise.- Since:
- 3.4
-
apply
public CommandLine.Help.Ansi.Text apply(String plainText, List<CommandLine.Help.Ansi.IStyle> styles) Returns a new Text object where all the specified styles are applied to the full length of the specified plain text.
- Parameters:
plainText- the string to apply all styles to. Must not contain markup!styles- the styles to apply to the full plain text- Returns:
- a new Text object
-