Giter Club home page Giter Club logo

terminal-table-output's Introduction

terminal-table-output

Create and print tables in the terminal.

NPM

Installation

npm install terminal-table-output

Usage

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    |
(*)(*)(*)(*)(*)(*)(*)(*)(*)

Functions

col(anyString)

col takes any string and pushes this into the last row.

row()

row creates a new row, using col after this will push into the new row

pushrow(arrayOfStrings)

creates a new row from the array of strings inserted into the function

line(anyString)

create a horizontal line in the table output, line takes a string argument as the char of string used in that specific line.

Settings

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: "="

terminal-table-output's People

Contributors

arwidt avatar shalecraig avatar

Stargazers

JingwenTian avatar  avatar

Watchers

 avatar zhukefeng avatar

Forkers

shalecraig

terminal-table-output's Issues

Add support for chalk

When input to a column is created with chalk the size is wrong, probably cant count chars but need to check the actual string chars without whatever chalk adds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.