java.lang.Object
dev.metaschema.cli.processor.ansi.Ansi
A minimal ANSI escape-code builder used by the CLI to emit colored and
formatted terminal output.
Emits a subset of
Select
Graphic Rendition codes for foreground colors, bold, and reset. When
globally disabled via setEnabled(boolean), escape sequences are
suppressed while appended literal text is preserved so output remains
readable on terminals that do not interpret ANSI codes.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiona(char ch) Append a single literal character.a(CharSequence text) Append a literal string.static Ansiansi()Create a new builder.bold()Enable bold rendering for subsequent appended text.boldOff()Disable bold rendering for subsequent appended text.fgBright(Ansi.Color color) Set the foreground color to the bright variant of the supplied color.Set the foreground color to bright blue.Set the foreground color to bright cyan.Set the foreground color to bright red.Set the foreground color to bright yellow.fgRed()Set the foreground color to red.Append formatted text usingString.format(String, Object...)semantics.static booleanIndicates whether ANSI escape code emission is currently enabled.reset()Emit the ANSI reset sequence, clearing any active color or style.static voidsetEnabled(boolean enable) Globally enable or disable emission of ANSI escape codes.toString()
-
Method Details
-
ansi
Create a new builder.- Returns:
- a fresh builder with empty contents
-
setEnabled
public static void setEnabled(boolean enable) Globally enable or disable emission of ANSI escape codes.When disabled, all color and style methods are no-ops; literal appended text is still emitted.
- Parameters:
enable-trueto emit escape sequences,falseto suppress them
-
isEnabled
public static boolean isEnabled()Indicates whether ANSI escape code emission is currently enabled.- Returns:
trueif enabled
-
a
Append a single literal character.- Parameters:
ch- the character to append- Returns:
thisfor chaining
-
a
Append a literal string.- Parameters:
text- the text to append- Returns:
thisfor chaining
-
format
Append formatted text usingString.format(String, Object...)semantics.- Parameters:
format- the format stringargs- the format arguments- Returns:
thisfor chaining
-
reset
Emit the ANSI reset sequence, clearing any active color or style.- Returns:
thisfor chaining
-
bold
Enable bold rendering for subsequent appended text.- Returns:
thisfor chaining
-
boldOff
Disable bold rendering for subsequent appended text.- Returns:
thisfor chaining
-
fgRed
Set the foreground color to red.- Returns:
thisfor chaining
-
fgBrightRed
Set the foreground color to bright red.- Returns:
thisfor chaining
-
fgBrightYellow
Set the foreground color to bright yellow.- Returns:
thisfor chaining
-
fgBrightBlue
Set the foreground color to bright blue.- Returns:
thisfor chaining
-
fgBrightCyan
Set the foreground color to bright cyan.- Returns:
thisfor chaining
-
fgBright
Set the foreground color to the bright variant of the supplied color.- Parameters:
color- the base color- Returns:
thisfor chaining
-
toString
-