A library for styling your terminal in Motoko!
Easy to use, expressive API:
import Writer "mo:color/Writer";
import TextStyle "mo:color/TextStyle";
let { backgroundColor; textColor } = TextStyle;
let writer = Writer.Writer();
writer
.text("hello world")
.textColor(textColor.black)
.backgroundColor(backgroundColor.white)
.bold(true)
.print();
Chain multiple colors on the same line:
...
import Debug "mo:base/Debug";
Debug.print(
writer
.text("It's easy being green")
.textColor(textColor.green)
.read()
# ", however... " #
writer
.text("I really love purple backgrounds!")
.backgroundColor(backgroundColor.purple)
.read()
);
Use RGB colors for the text or background:
writer
.text("woah dude, RGB!")
.textColorRGB(20,40,60)
.backgroundColorRGB(180,200,220)
.print();
Immutable text styling settings, so use it all over the place, and don't worry about overwriting a bound setting.
let greenCheckMark = writer
.text("✓")
.textColor(textColor.green)
.backgroundColor(backgroundColor.white);
let redCheckMark = greenCheckMark
.textColor(textColor.red);
greenCheckMark.print();
redCheckMark.print();
Further documentation for the latest release can be found at https://byronbecker.github.io/motoko-color.
If you'd like to generate documentation locally run $(vessel bin)/mo-doc && firefox docs/index.html
See the example folder for usage,
making sure that both vessel and wasmtime are installed before running make run-example
from the root directory.
Credits to Christopher Hegemann for motoko-library-template that helped jumpstart this library
motoko-color is distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.