Class Terminal

java.lang.Object
com.helixframework.console.Terminal

public final class Terminal extends Object
Terminal utility.
  • Method Details

    • isInteractive

      public static boolean isInteractive()
      Determines whether the current terminal session is interactive. The method checks various conditions to make this determination: - If the environment variable "NO_COLOR" is set, the session is considered non-interactive. - If the environment variable "CI" is truthy, the session is considered non-interactive. - If a system console is available, the session is considered interactive. - If the "TERM" environment variable is set, the session is considered interactive.
      Returns:
      true if the current terminal session is interactive; false otherwise
    • shouldUseAnsi

      public static boolean shouldUseAnsi(Terminal.ColorMode colorMode)
      Determines if ANSI escape codes should be used based on the specified color mode and the interactivity of the current terminal session. The decision is made as follows: - If colorMode is ColorMode.ALWAYS, ANSI codes will always be used. - If colorMode is ColorMode.NEVER, ANSI codes will never be used. - If colorMode is ColorMode.AUTO, ANSI codes will be used only if the terminal session is determined to be interactive (as per the isInteractive method).
      Parameters:
      colorMode - the color mode used to determine whether ANSI codes should be enabled. Possible values are ColorMode.AUTO, ColorMode.ALWAYS, and ColorMode.NEVER
      Returns:
      true if ANSI escape codes should be used, false otherwise