Skip to content

Commit 6cc4f84

Browse files
committed
add TextFormatter#getNoColorEnvironment
1 parent 9d177c8 commit 6cc4f84

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/textFormatter/TextFormatter.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@ else if (TextFormatter.startWithDefaultColorIfNotDefined && this.parent == null)
383383
return "" + ESC + '[' + joined + 'm';
384384
}
385385

386+
/**
387+
* Returns whether there is an environment variable that specifies that
388+
* the terminal does not support color.
389+
* <a href="https://no-color.org/">NO_COLOR.org</a>
390+
* @return {@code true} if the terminal supports color
391+
*/
392+
public static boolean getNoColorEnvironment() {
393+
return System.getenv("NO_COLOR") != null;
394+
}
395+
386396
/**
387397
* Escape character which represents the start of a terminal sequence
388398
*/

0 commit comments

Comments
 (0)