Create and print tables in the terminal.
npm install terminal-table-output
Use this syntax
var tto = require('terminal-table-output').create();
tto.col('foo')
.col('bar')
.col('foobar')
.row()
.col('onoff')
.col('extraextra')
.line()
.col('line')
.col('special')
.line('(*)')
.print(true);
or this
tto.pushrow(['foo', 'bar', 'foobar'])
.pushrow(['onoff', 'extraextra'])
.line()
.pushrow(['line', 'special'])
.line("(*)")
.print(true);
both will output
foo | bar | foobar
onoff | extraextra |
===========================
line | special |
(*)(*)(*)(*)(*)(*)(*)(*)(*)
col takes any string and pushes this into the last row.
row creates a new row, using col after this will push into the new row
creates a new row from the array of strings inserted into the function
create a horizontal line in the table output, line takes a string argument as the char of string used in that specific line.
You can send in a settings object with the create function.
With these you can set the character that fills the text that has less width than the longest.
And you can set the delimiter between columns.
var tto = require('terminal-table-output')
.create({
fill: "-",
border: "/",
line: ">"
});
Would output the example above in the following way.
foo--/bar-------/foobar
onoff/extraextra/
>>>>>>>>>>>>>>>>>>>>>>>
table/delay-----/
Default settings
fill: " "
border: " | "
line: "="