/chalk

Bring colors to Ballerina programs

Primary LanguageBallerinaApache License 2.0Apache-2.0

Chalk

Bring colors to Ballerina programs.

chalk

Supported colors

  1. Black
  2. Red
  3. Green
  4. Yellow
  5. Blue
  6. Purple
  7. Cyan
  8. White

Supported text properties

  1. Underline
  2. Italicize
  3. Reverse (background and foreground colors)
  4. Dark color mode
  5. Light color mode

Sample

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]