Package com.helixframework.console
Class Terminal
java.lang.Object
com.helixframework.console.Terminal
Terminal utility.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the available color modes for terminal output. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDetermines whether the current terminal session is interactive.static booleanshouldUseAnsi(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.
-
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
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: - IfcolorModeisColorMode.ALWAYS, ANSI codes will always be used. - IfcolorModeisColorMode.NEVER, ANSI codes will never be used. - IfcolorModeisColorMode.AUTO, ANSI codes will be used only if the terminal session is determined to be interactive (as per theisInteractivemethod).- Parameters:
colorMode- the color mode used to determine whether ANSI codes should be enabled. Possible values areColorMode.AUTO,ColorMode.ALWAYS, andColorMode.NEVER- Returns:
trueif ANSI escape codes should be used,falseotherwise
-