java.lang.Object
dev.metaschema.cli.processor.ansi.Ansi

public final class Ansi extends Object
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.

  • Method Details

    • ansi

      @NonNull public static Ansi 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 - true to emit escape sequences, false to suppress them
    • isEnabled

      public static boolean isEnabled()
      Indicates whether ANSI escape code emission is currently enabled.
      Returns:
      true if enabled
    • a

      @NonNull public Ansi a(char ch)
      Append a single literal character.
      Parameters:
      ch - the character to append
      Returns:
      this for chaining
    • a

      @NonNull public Ansi a(@NonNull CharSequence text)
      Append a literal string.
      Parameters:
      text - the text to append
      Returns:
      this for chaining
    • format

      @NonNull public Ansi format(@NonNull String format, Object... args)
      Append formatted text using String.format(String, Object...) semantics.
      Parameters:
      format - the format string
      args - the format arguments
      Returns:
      this for chaining
    • reset

      @NonNull public Ansi reset()
      Emit the ANSI reset sequence, clearing any active color or style.
      Returns:
      this for chaining
    • bold

      @NonNull public Ansi bold()
      Enable bold rendering for subsequent appended text.
      Returns:
      this for chaining
    • boldOff

      @NonNull public Ansi boldOff()
      Disable bold rendering for subsequent appended text.
      Returns:
      this for chaining
    • fgRed

      @NonNull public Ansi fgRed()
      Set the foreground color to red.
      Returns:
      this for chaining
    • fgBrightRed

      @NonNull public Ansi fgBrightRed()
      Set the foreground color to bright red.
      Returns:
      this for chaining
    • fgBrightYellow

      @NonNull public Ansi fgBrightYellow()
      Set the foreground color to bright yellow.
      Returns:
      this for chaining
    • fgBrightBlue

      @NonNull public Ansi fgBrightBlue()
      Set the foreground color to bright blue.
      Returns:
      this for chaining
    • fgBrightCyan

      @NonNull public Ansi fgBrightCyan()
      Set the foreground color to bright cyan.
      Returns:
      this for chaining
    • fgBright

      @NonNull public Ansi fgBright(@NonNull Ansi.Color color)
      Set the foreground color to the bright variant of the supplied color.
      Parameters:
      color - the base color
      Returns:
      this for chaining
    • toString

      public String toString()
      Overrides:
      toString in class Object