public static enum CommandLine.Help.Ansi extends Enum<CommandLine.Help.Ansi>
Modifier and Type | Class and Description |
---|---|
static interface |
CommandLine.Help.Ansi.IStyle
Defines the interface for an ANSI escape sequence.
|
static class |
CommandLine.Help.Ansi.Style
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.
|
class |
CommandLine.Help.Ansi.Text
Encapsulates rich text with styles and colors.
|
Enum Constant and Description |
---|
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). |
OFF
Forced OFF: never emit ANSI escape code regardless of the platform.
|
ON
Forced ON: always emit ANSI escape code regardless of the platform.
|
Modifier and Type | Method and Description |
---|---|
CommandLine.Help.Ansi.Text |
apply(String plainText,
List<CommandLine.Help.Ansi.IStyle> styles)
Deprecated.
use
CommandLine.Help.ColorScheme.apply(String, List) instead |
boolean |
enabled()
Returns
true if ANSI escape codes should be emitted, false otherwise. |
String |
string(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.Text |
text(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.Ansi |
valueOf(boolean enabled)
Returns Ansi.ON if the specified
enabled flag is true, Ansi.OFF otherwise. |
static CommandLine.Help.Ansi |
valueOf(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.
|
public static final CommandLine.Help.Ansi AUTO
"picocli.ansi"
is not set to any value other than "true"
(case insensitive).public static final CommandLine.Help.Ansi ON
public static final CommandLine.Help.Ansi OFF
public static CommandLine.Help.Ansi[] values()
for (CommandLine.Help.Ansi c : CommandLine.Help.Ansi.values()) System.out.println(c);
public static CommandLine.Help.Ansi valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic boolean enabled()
true
if ANSI escape codes should be emitted, false
otherwise.true
, OFF: false
, AUTO: if system property "picocli.ansi"
has value
"tty"
(case-insensitive), then return true
if either System.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 return true
.
Otherwise use picocli's Heuristics for Enabling ANSI
to determine whether the platform supports ANSI escape codes.public CommandLine.Help.Ansi.Text text(String stringWithMarkup)
@|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)
.
CommandLine.Help.ColorScheme.text(String)
public String string(String stringWithMarkup)
@|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()
.
CommandLine.Help.ColorScheme.string(String)
public static CommandLine.Help.Ansi valueOf(boolean enabled)
enabled
flag is true, Ansi.OFF otherwise.@Deprecated public CommandLine.Help.Ansi.Text apply(String plainText, List<CommandLine.Help.Ansi.IStyle> styles)
CommandLine.Help.ColorScheme.apply(String, List)
instead