This utility allows you to render unicode-aided tables on the command line from
your node.js scripts.
cli-table3 is based on (and api compatible with) the original cli-table,
and cli-table2, which are both
unmaintained. cli-table3 includes all the additional features from
cli-table2.
Features not in the original cli-table
Ability to make cells span columns and/or rows.
Ability to set custom styles per cell (border characters/colors, padding, etc).
Empty decoration lines will be skipped, to avoid vertical separator rows just
set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string:
var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} });table.push( ['foo', 'bar', 'baz'] , ['frobnicate', 'bar', 'quuz']);console.log(table.toString());// Outputs: (note the lack of the horizontal line between rows)//┌────────────┬─────┬──────┐//│ foo │ bar │ baz │//│ frobnicate │ bar │ quuz │//└────────────┴─────┴──────┘
By setting all chars to empty with the exception of 'middle' being set to a
single space and by setting padding to zero, it's possible to get the most
compact layout with no decorations:
Original cli-table code/documentation: Copyright (c) 2010 LearnBoost <dev@learnboost.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.