CLI Utilities Toolkit

1.1.27 · abandoned · verified Sun Apr 19

cli-util is an abandoned Node.js package providing a collection of utility functions designed for building command-line interface applications. It offers basic functionalities for logging, styled output (colors, headers, indentation), string padding, and column formatting. The package is built on top of very old versions of `colors` (0.6.2) and `commander` (2.0.0) for styling and argument parsing, respectively. Its last update was in 2014, making it unsuitable for modern projects due to outdated dependencies, lack of maintenance, and CommonJS-only module format. There is no active development or defined release cadence, and the current stable version is 1.1.27.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of cli-util for logging, styling output with colors, displaying headers, and formatting text in columns and with padding.

const cli = require('cli-util');

// Logging with colors (due to internal 'colors' dependency modifying String.prototype)
cli.log('Starting CLI application...'.green);
cli.warn('A warning message.'.yellow);
cli.error('An error occurred!'.red);

// Displaying a header
cli.header('CLI-Util Example', { indent: 1 });

// Formatting lines and columns
const data = [
  ['Name:', 'John Doe'],
  ['Email:', 'john.doe@example.com'],
  ['Status:', 'Active']
];
cli.lines(data.map(row => cli.pad(row[0], 10) + row[1]));

console.log(cli.line()); // Prints a separator line

// Example of padding
const paddedText = cli.rightPad('Hello', 15, '.');
cli.log(`Padded text: ${paddedText}`);

cli.ok('Application finished successfully.'.blue);

view raw JSON →