diff --git a/pairgoth-common/src/main/kotlin/org/jeudego/pairgoth/util/Colorizer.kt b/pairgoth-common/src/main/kotlin/org/jeudego/pairgoth/util/Colorizer.kt index f3d2a09..20d90bd 100644 --- a/pairgoth-common/src/main/kotlin/org/jeudego/pairgoth/util/Colorizer.kt +++ b/pairgoth-common/src/main/kotlin/org/jeudego/pairgoth/util/Colorizer.kt @@ -3,6 +3,7 @@ package org.jeudego.pairgoth.util import com.diogonunes.jcolor.Ansi import com.diogonunes.jcolor.AnsiFormat import com.diogonunes.jcolor.Attribute +import java.util.* private val blue = AnsiFormat(Attribute.BRIGHT_BLUE_TEXT()) private val green = AnsiFormat(Attribute.BRIGHT_GREEN_TEXT()) @@ -11,8 +12,10 @@ private val bold = AnsiFormat(Attribute.BOLD()) object Colorizer { - fun blue(str: String) = Ansi.colorize(str, blue) - fun green(str: String) = Ansi.colorize(str, green) - fun red(str: String) = Ansi.colorize(str, red) - fun bold(str: String) = Ansi.colorize(str, bold) + val colorize = System.getProperty("os.name").lowercase(Locale.ROOT).contains(Regex("nix|nux|aix")) + + fun blue(str: String) = if (colorize) Ansi.colorize(str, blue) else str + fun green(str: String) = if (colorize) Ansi.colorize(str, green) else str + fun red(str: String) = if (colorize) Ansi.colorize(str, red) else str + fun bold(str: String) = if (colorize) Ansi.colorize(str, bold) else str }