Package picocli
Enum CommandLine.Help.Ansi
- java.lang.Object
-
- java.lang.Enum<CommandLine.Help.Ansi>
-
- picocli.CommandLine.Help.Ansi
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<CommandLine.Help.Ansi>
- Enclosing class:
- CommandLine.Help
public static enum CommandLine.Help.Ansi extends java.lang.Enum<CommandLine.Help.Ansi>
Provides methods and inner classes to support using ANSI escape codes in usage help messages.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCommandLine.Help.Ansi.IStyleDefines the interface for an ANSI escape sequence.static classCommandLine.Help.Ansi.StyleA 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.classCommandLine.Help.Ansi.TextEncapsulates rich text with styles and colors.
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTOOnly 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).OFFForced OFF: never emit ANSI escape code regardless of the platform.ONForced ON: always emit ANSI escape code regardless of the platform.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CommandLine.Help.Ansi.Textapply(java.lang.String plainText, java.util.List<CommandLine.Help.Ansi.IStyle> styles)Deprecated.useCommandLine.Help.ColorScheme.apply(String, List)insteadbooleanenabled()Returnstrueif ANSI escape codes should be emitted,falseotherwise.java.lang.Stringstring(java.lang.String stringWithMarkup)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.CommandLine.Help.Ansi.Texttext(java.lang.String stringWithMarkup)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.AnsivalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static CommandLine.Help.Ansi[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
AUTO
public static final CommandLine.Help.Ansi 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
public static final CommandLine.Help.Ansi ON
Forced ON: always emit ANSI escape code regardless of the platform.
-
OFF
public static final CommandLine.Help.Ansi OFF
Forced OFF: never emit ANSI escape code regardless of the platform.
-
-
Method Detail
-
values
public static CommandLine.Help.Ansi[] 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 (CommandLine.Help.Ansi c : CommandLine.Help.Ansi.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CommandLine.Help.Ansi 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
-
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
public CommandLine.Help.Ansi.Text text(java.lang.String stringWithMarkup)
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).- Since:
- 3.4
- See Also:
CommandLine.Help.ColorScheme.text(String)
-
string
public java.lang.String string(java.lang.String stringWithMarkup)
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().- Since:
- 3.4
- See Also:
CommandLine.Help.ColorScheme.string(String)
-
valueOf
public static CommandLine.Help.Ansi valueOf(boolean enabled)
Returns Ansi.ON if the specifiedenabledflag is true, Ansi.OFF otherwise.- Since:
- 3.4
-
apply
@Deprecated public CommandLine.Help.Ansi.Text apply(java.lang.String plainText, java.util.List<CommandLine.Help.Ansi.IStyle> styles)
Deprecated.useCommandLine.Help.ColorScheme.apply(String, List)instead
-
-