From 2ef5976879123accb0f9adc22c0014eb0310e298 Mon Sep 17 00:00:00 2001 From: tksk Date: Wed, 10 Jul 2013 02:04:09 +0900 Subject: [PATCH] support jansi.force property to force ansi escapes --- jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java index 91f6239a..060a2645 100644 --- a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java +++ b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java @@ -72,10 +72,13 @@ public static OutputStream wrapOutputStream(final OutputStream stream) { // We must be on some unix variant.. try { + // If the jansi.force property is set, then we force to output + // the ansi escapes for piping it into ansi color aware commands (e.g. less -r) + boolean forceColored = Boolean.getBoolean("jansi.force"); // If we can detect that stdout is not a tty.. then setup // to strip the ANSI sequences.. int rc = isatty(STDOUT_FILENO); - if( rc==0 ) { + if( !forceColored && rc==0 ) { return new AnsiOutputStream(stream); }