Skip to content

Color

Terminal color formatting — returns styled strings.

Methods

MethodReturnsDescription
Color.red(s)stringRed text
Color.green(s)stringGreen text
Color.yellow(s)stringYellow text
Color.blue(s)stringBlue text
Color.magenta(s)stringMagenta text
Color.cyan(s)stringCyan text
Color.gray(s)stringGray text
Color.bold(s)stringBold text
Color.dim(s)stringDim text
Color.underline(s)stringUnderlined text

Examples

wyn
println(Color.bold("=== My App ==="))
println(Color.red("Error: file not found"))
println(Color.yellow("Warning: deprecated"))
println(Color.green("Success!"))
println(Color.cyan("Info: ") + "server running on port 8080")
println(Color.gray("debug: gc completed"))

Composing

Colors return strings, so they compose naturally:

wyn
var header = Color.bold(Color.cyan("myapp"))
var status = Color.green("ok")
println("${header} -- ${status}")

MIT License