status-line

Single-line status functionality to TTYs

npm install status-line
8 downloads in the last month

Status Line


Allows for simple one-line status displaying with progress animation (finite or infinite) while retaining the logging ability. Writes only to stdout through readline, for no TTY falls back to console.log.

Usage

var sl = require('status-line');

sl('Waiting...');
sl.log('Hello world!');
// 'Waiting…' remains the last line 
// with progress animation

var p = 0;
sl.progress(p, 'Working on something');
var intId = setInterval(function () {
  sl.progress(++p/10);
  if (p === 10) {
    sl.finish('All stuff is done');
    clearInterval(intId);
  }
}, 500);

Methods (all chainable):

log, warn, error - log a message while still retaining the status line.
fatalError - kill execution with an error message.

pause, resume - hide/show progress animation.
hide, show - hide/show the status line altogether.
show is actually an alias to the main function. Without a new message, the last one will be displayed.

progress(progress, [message]) - displays a finite progress bar. Progress must be between 0 and 1. Pass false in the first argument to return to infinite progress animation.

timeless, timestamped - turn on/off time displaying.

lap - log a message in green (to show that one of the tasks is finished) finish - must be called when your script finished all tasks.

All methods except hide can receive a message as argument.

npm loves you