Simple CLI table for simple people
npm i cli-simple-table
import SimpleTable from 'cli-simple-table'
import chalk from 'chalk'
const table = new SimpleTable()
table.header('Name', 'Emoji')
table.row(chalk.red('Squid'), 'π¦')
table.row(chalk.green('Frog'), 'πΈ')
table.row(chalk.yellow('Tiger'), 'π―')
table.row(chalk.blue('Whale'), 'π³')
table.row(chalk.magenta('Unicorn'), 'π¦')
table.row(chalk.cyan('Dolphin'), 'π¬')
table.row(chalk.white('Panda'), 'πΌ')
console.log(table.toString())
const table = new SimpleTable()
table.header(
'Name',
{
text: 'Age',
align: 'right'
}
)
table.row('Steve', 26)
console.log(table.toString())
const table = new SimpleTable()
table.header(
{
text: 'Long text',
maxWidth: 25
},
{
text: 'Long long text',
maxWidth: 25
}
)
table.row('Truncates really really long text', chalk.magenta('Colored long long text too'))
console.log(table.toString())
-
columnPadding
<Number>
(10
) - Number of characters to pad the column content with -
headerSeparator
<Number>
(1
) - Number of lines that separate the header from the table body