Skip to content

Package io.github.qishr.cascara.common.util

Enum Ansi

java.lang.Object
        java.lang.Enum<io.github.qishr.cascara.common.util.CommandLine.Help.Ansi>
                io.github.qishr.cascara.common.util.CommandLine.Help.Ansi

Enclosing Class:
    io.github.qishr.cascara.common.util.CommandLine.Help


public static final enum Ansi
extends Enum<Ansi>

Provides methods and inner classes to support using ANSI escape codes in usage help messages.

Nested Class Summary

Modifier and Type Class Description
public io.github.qishr.cascara.common.util.CommandLine.Help.Ansi.Text Encapsulates rich text with styles and colors.

Enum Constants

Enum Constant Description
AUTO
ON
OFF

Method Summary

Modifier and Type Method Description
public static Ansi[] values()
public static Ansi valueOf(String name)
public boolean enabled() Returns true if ANSI escape codes should be emitted, false otherwise.
public 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|@.
public 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.
public static Ansi valueOf(boolean enabled) Returns Ansi.ON if the specified enabled flag is true, Ansi.OFF otherwise.
public Text apply(String plainText, List<IStyle> styles)

Enum Constant Details

AUTO

public static final AUTO


ON

public static final ON


OFF

public static final OFF


Method Details

values

public static Ansi[] values()


valueOf

public static Ansi valueOf(String name)


enabled

public boolean enabled()

Returns true 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 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.


text

public 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|@.

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:

text


string

public 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.

Equivalent to this.new Text(stringWithMarkup).toString().

Since:

3.4

See Also:

string


valueOf

public static Ansi valueOf(boolean enabled)

Returns Ansi.ON if the specified enabled flag is true, Ansi.OFF otherwise.

Since:

3.4


apply

public Text apply(String plainText, List<IStyle> styles)

Deprecation

use ColorScheme.apply instead