ternal
v1.0.3
Published
A node library for easily formatting console output.
Downloads
15
Readme
Ternal
A node library for easily formatting console output.
Install
npm install ternal
Usage
The quick way:
const { echo } = require('ternal');
echo('blue', 'Hello World');
Output:
Using a ternal instance:
const Ternal = require('ternal');
let ternal = new Ternal('blue');
ternal.print('Hello World');
Output:
New instance with blue background:
let ternal = new Ternal({
bg:'blue'
});
ternal.print('Hello World');
Output:
Same instance, change color:
ternal.set({color:'red'}).print('Hello World');
Output:
Remove background and underline text:
ternal.set({bg: null, format: 'underline'}).print('Hello World');
Output:
Reset to defaults:
ternal.reset().print('Hello World');
Output:
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:
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:
foo:bar foo$ xternal --reset
foo:bar foo$ echo "Hello World"