Package 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 interface
Defines the interface for an ANSI escape sequence.(package private) static class
Defines a palette map of 216 colors: 6 * 6 * 6 cube (216 colors): 16 + 36 * r + 6 * g + b (0 <= r, g, b <= 5).static enum
A 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.private static class
class
Encapsulates 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. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static CommandLine.Help.Ansi.Text
(package private) static Boolean
Caches the result of methodisJansiConsoleInstalled()
so it doesn't repeatedly call Class#forName, which can cause performance issues.(package private) static Boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static boolean
apply
(String plainText, List<CommandLine.Help.Ansi.IStyle> styles) Deprecated.(package private) static boolean
Returnsfalse
if system propertyorg.fusesource.jansi.Ansi.disable
is set to"true"
(case-insensitive); otherwise, returnsfalse
if the Jansi library is in the classpath but has been disabled (either via system propertyorg.fusesource.jansi.Ansi.disable
or via a Jansi API call); otherwise, returnstrue
if the Jansi library is in the classpath and has been installed.(package private) static boolean
calcTTY()
http://stackoverflow.com/questions/1403772/how-can-i-check-if-a-java-programs-input-output-streams-are-connected-to-a-termboolean
enabled()
Returnstrue
if ANSI escape codes should be emitted,false
otherwise.(package private) static final boolean
https://no-color.org/(package private) static final boolean
Jan Niklas Hasse's https://bixense.com/clicolors/ proposal(package private) static final boolean
(package private) static final boolean
(package private) static final boolean
https://github.com/adoxa/ansicon/blob/master/readme.txt, Jan Niklas Hasse's https://bixense.com/clicolors/ proposal, https://conemu.github.io/en/AnsiEscapeCodes.html#Environment_variable(package private) static final boolean
isCygwin()
(package private) static boolean
The first time this method is called, it invokes thecalcIsJansiConsoleInstalled()
method, caches its result and returns this result; subsequently it returns the cached result.(package private) static final boolean
isMac()
(package private) static boolean
Cygwin and MSYS use pseudo-tty and console is always null...(package private) static boolean
isTTY()
(package private) static final boolean
(package private) static final boolean
isXterm()
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.Ansi
valueOf
(boolean enabled) Returns Ansi.ON if the specifiedenabled
flag is true, Ansi.OFF otherwise.static CommandLine.Help.Ansi
Returns 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.
-
-
Field Details
-
EMPTY_TEXT
-
tty
-
jansiInstalled
Caches the result of methodisJansiConsoleInstalled()
so it doesn't repeatedly call Class#forName, which can cause performance issues.
-
-
Constructor Details
-
Ansi
private Ansi()
-
-
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
-
isTTY
static boolean isTTY() -
isWindows
static final boolean isWindows() -
isMac
static final boolean isMac() -
isXterm
static final boolean isXterm() -
isCygwin
static final boolean isCygwin() -
hasOsType
static final boolean hasOsType() -
hintDisabled
static final boolean hintDisabled() -
hintEnabled
static final boolean hintEnabled()https://github.com/adoxa/ansicon/blob/master/readme.txt, Jan Niklas Hasse's https://bixense.com/clicolors/ proposal, https://conemu.github.io/en/AnsiEscapeCodes.html#Environment_variable -
forceDisabled
static final boolean forceDisabled()https://no-color.org/ -
forceEnabled
static final boolean forceEnabled()Jan Niklas Hasse's https://bixense.com/clicolors/ proposal -
calcTTY
static boolean calcTTY()http://stackoverflow.com/questions/1403772/how-can-i-check-if-a-java-programs-input-output-streams-are-connected-to-a-term -
isPseudoTTY
static boolean isPseudoTTY()Cygwin and MSYS use pseudo-tty and console is always null... -
ansiPossible
static boolean ansiPossible() -
isJansiConsoleInstalled
static boolean isJansiConsoleInstalled()The first time this method is called, it invokes thecalcIsJansiConsoleInstalled()
method, caches its result and returns this result; subsequently it returns the cached result. -
calcIsJansiConsoleInstalled
static boolean calcIsJansiConsoleInstalled()Returnsfalse
if system propertyorg.fusesource.jansi.Ansi.disable
is set to"true"
(case-insensitive); otherwise, returnsfalse
if the Jansi library is in the classpath but has been disabled (either via system propertyorg.fusesource.jansi.Ansi.disable
or via a Jansi API call); otherwise, returnstrue
if the Jansi library is in the classpath and has been installed. -
enabled
public boolean enabled()Returnstrue
if ANSI escape codes should be emitted,false
otherwise.- Returns:
- ON:
true
, OFF:false
, AUTO: if system property"picocli.ansi"
has value"tty"
(case-insensitive), then returntrue
if eitherSystem.console() != null
or 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)
.- Since:
- 3.4
- See Also:
-
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()
.- Since:
- 3.4
- See Also:
-
valueOf
Returns Ansi.ON if the specifiedenabled
flag is true, Ansi.OFF otherwise.- Since:
- 3.4
-
apply
@Deprecated public CommandLine.Help.Ansi.Text apply(String plainText, List<CommandLine.Help.Ansi.IStyle> styles) Deprecated.useCommandLine.Help.ColorScheme.apply(String, List)
instead
-
CommandLine.Help.ColorScheme.apply(String, List)
instead