Skip to main content

Color

extras.scala.io.syntax

extras-scala-io provides syntax to use scala.io.AnsiColor easily (The missing ones will be added later).

import extras.scala.io.syntax.color._
import extras.scala.io.syntax.color._

"Hello".blue
// res2: String = "\u001b[34mHello\u001b[0m"

"Hello".red
// res3: String = "\u001b[31mHello\u001b[0m"

"Hello".green
// res4: String = "\u001b[32mHello\u001b[0m"

"Hello".bold
// res5: String = "\u001b[1mHello\u001b[0m"

"Hello".underlined
// res6: String = "\u001b[4mHello\u001b[0m"

println("Hello".blue)
// Hello

println("Hello".red)
// Hello

println("Hello".green)
// Hello

println("Hello".bold)
// Hello

println("Hello".underlined)
// Hello

AnsiColor syntax support Example 1 AnsiColor syntax support Example 2

You can also chain them like this.

import extras.scala.io.syntax.color._

println("Hello".blue)
// Hello

println("Hello".blue.bold)
// Hello

println("Hello".blue.bold.underlined)
// Hello

println("Hello".underlined.bold.blue)
// Hello

AnsiColor syntax support Example 3