Bring colors to Ballerina programs.
- Black
- Red
- Green
- Yellow
- Blue
- Purple
- Cyan
- White
- Underline
- Italicize
- Reverse (background and foreground colors)
- Dark color mode
- Light color mode
First, import the chalk package.
import shan1024/chalk;
Create a new chalk
object. The first argument is the foreground color and the second argument is the background color.
chalk:Chalk chalk = new(chalk:WHITE, chalk:RED);
You can make the text italicized and underlined as well through default-able parameters.
chalk:Chalk chalk = new(chalk:WHITE, chalk:RED, italicize = true, underline = true);
Start colorizing your texts.
string colorizedText = chalk.write("Hello world !!!");
io:println(colorizedText);
Chained invocations are supported.
string colorizedText = chalk.dark().italicize().reverse().write("Hello world !!!");
io:println(colorizedText);
So you can customize the chalk any way you want. Cool, right !!! ;)
[Inspired by the node module with the same name]