tabletops

    0.1.4 • Public • Published

    Tabletops

    A small tool that makes displaying tables in the terminal easy.

    Table of Contents

    Installation

    npm install tabletops --save

    Usage

    const CliTable = require('tabletops');

    Requires the module.

    const table = new CliTable();

    Creates a new table.

    table.SetTableTitle("Test Table");

    Sets the title of the table.

    table.SetTableColumns([
        {
            key: 'id',
            title: '#',
            width: 10
        },
        {
            key: 'name',
            title: 'Name',
            width: 24
        }
    ]);

    Sets table column keys, their shown title and the width of the column.

    table.SetTableRows([
        {
            id: 1,
            name: 'John Doe'
        },
        {
            id: 2,
            title: 'Jane Doe'
        }
    ]);

    Sets rows for the table.

    table.AddTableFooter("Rows: " + table.GetRowAmount());

    Shows a footer at the bottom of the table, showing the amount of rows in the table.

    table.ShowTable();

    Shows the table.

    Advanced Usage

    table.AddTableRow(
        {
            id: 47,
            title: 'James T. Kirk'
        }
    );

    Interactively adds a new row to the table (you should not add a footer to the specified table, as the outcome might look strange.)

    Tests

    npm test

    Release History

    • 0.1.0 - Initial Release
    • 0.1.1 - Implemented tests
    • 0.1.2 - Updated package.json
    • 0.1.3 - Added async functionality

    License

    Copyright (c) 2019 F. Rick Reich. Licensed under the terms of the MIT license. http://frickreich.mit-license.org/

    Install

    npm i tabletops

    DownloadsWeekly Downloads

    1

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    13.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • frederikreich