cli-styler

0.1.0 • Public • Published

Installation

npm install cli-styler

Usage

In this example we will put cli-styler in the variable cs.

var cs = require('cli-styler');

Clear screen

Clear the console screen.

cs.clearScreen('cli-styler');

Short console log

Prevent wrist injuries, use the short console log.

cs.l('Hello world');

Write text

Write text to the console based on process.stdout.write. Extra options are 'text alignment' and 'prevent new line after text'.

cs.writeText('Hello world');
cs.writeText('Hi, we are ', 'left', true) /* Set the text alignment, prevent new line after text */;
cs.write('on the same line') /* Same as writeText() */;
cs.writeText('Wow, I am centered', 'center');
cs.writeText('Looks good, right?', 'right');

Write characters (loop)

Write characters in a loop to the console. Handy to write multiple spaces or line breaks. Internal used in writeText() for positioning text. Also available as get function.

cs.writeCharacters('Loopy Loop ', 3);
cs.writeChars(' ', 5) /* Same as writeCharacters() */;
cs.write(cs.getCharacters('Whoop Loop ', 3)) /* Get character */;
cs.writeCharacters('\n', 3);

Get width and height

Return width and height.

cs.write('Console width : ' + cs.getConsoleWidth());
cs.write('Console height: ' +  cs.getConsoleHeight());

Write rule

Write a rule to the console. Choose your own character and size. By default the rule has the full width of your console and does not prevent a new line.

cs.writeRule();
cs.writeRule('.') /* Set character */;
cs.writeRule('=', 10, true) /* Set character, size and prevent new line after text */;

Package Sidebar

Install

npm i cli-styler

Weekly Downloads

2

Version

0.1.0

License

ISC

Last publish

Collaborators

  • benbesuijen