Yet another colors and formatting for the console solution
Colors, formatting and other goodies for the console. This package won't mess with built-ins and provides neat way to predefine formatting patterns, see below.
Installation
$ npm install cli-color
Usage
Usage:
var clc = require("cli-color");
Output colored text:
console.log(clc.red("Text in red"));
Styles can be mixed:
console.log(clc.red.bgWhite.underline("Underlined red text on white background."));
Create a text-graphical art. Within styleConf, string replacements needs to be defined, which are then used to convert text to styled graphical text.
var text = ".........\n" + ". Hello .\n" + ".........\n";var style = { ".": clc.yellowBright("X") };process.stdout.write(clc.art(text, style));
clc.columns(data[, options])
Outputs aligned table of columns.
data is expected to be an array (or other iterable structure) of rows, where each row is also an array (or other iterable structure) of content to display.
Supported options:
sep: Custom colums separator (defaults to |)
columns: Per column customizations, as e.g. [{ align: 'right' }, null, { align: 'left' }]:
align: Possible options: 'left', 'right (efaults to 'left')
var clc = require("cli-color");process.stdout.write( clc.columns([ [clc.bold("First Name"), clc.bold("Last Name"), clc.bold("Age")], ["John", "Doe", 34], ["Martha", "Smith", 20], ["Jan", "Kowalski", 30] ]));/* Outputs:First Name | Last Name | AgeJohn | Doe | 34Martha | Smith | 20Jan | Kowalski | 30*/
throbber(write, interval[, format])
Writes throbber string to write function at given interval. Optionally throbber output can be formatted with given format function
var setupThrobber = require("cli-color/throbber");var throbber = setupThrobber(function (str) { process.stdout.write(str); }, 200);throbber.start();// at any time you can stop/start throbberthrobber.stop();
Tests
$ npm test
Security contact information
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.