ternal

1.0.3 • Public • Published

Ternal

A node library for easily formatting console output.

Version Status Size License

Install

npm install ternal

Usage

The quick way:

const { echo } = require('ternal');
echo('blue', 'Hello World');
Output:

Hello World blue

Using a ternal instance:

const Ternal = require('ternal');

let ternal = new Ternal('blue');
ternal.print('Hello World');
Output:

Hello World blue

New instance with blue background:

let ternal = new Ternal({
    bg:'blue'
});
ternal.print('Hello World');
Output:

Hello World blue background

Same instance, change color:

    ternal.set({color:'red'}).print('Hello World');
Output:

Hello World red blue background

Remove background and underline text:

ternal.set({bg: null, format: 'underline'}).print('Hello World');
Output:

Hello World red underlined

Reset to defaults:

ternal.reset().print('Hello World');
Output:

Hello World plain text

Call ternal.set() with the second parameter set to true to change your terminal defaults:

ternal.set({
    color:'blue',
    bg:'white',
    format:'bold'
}, true);

console.log('I am blue and bold');
console.log('So am I')
ternal.reset('Let\'s go back to normal');
console.log('Now I\'m normal again');
Output:

Hello World multiline

Command Line

You can also use ternal straight from the command line:

foo:bar foo$ ternal set blue
#blue output
foo:bar foo$ ternal reset

Or use the command ternal globalize to place the xternal executable in your global path:

foo:bar foo$ ternal globalize

xternal command now globally executable.

foo:bar foo$ xternal blue

foo:bar foo$ echo "Hello World"
Output:

Hello World blue

foo:bar foo$ xternal --reset

foo:bar foo$ echo "Hello World"
Output:

Hello World blue

Package Sidebar

Install

npm i ternal

Weekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

77.1 kB

Total Files

20

Last publish

Collaborators

  • sgugg