1. cli-columns
Columnated lists for the CLI.
cli-columns
Package: cli-columns
Created by: shannonmoeller
Last modified: Sun, 05 Mar 2023 20:14:33 GMT
Version: 4.0.0
License: MIT
Downloads: 3,078,835
Repository: https://github.com/shannonmoeller/cli-columns

Install

npm install cli-columns
yarn add cli-columns

cli-columns

NPM version Downloads

Columnated lists for the CLI. Unicode and ANSI safe.

Install

$ npm install --save cli-columns

Usage

 const columns = require('cli-columns');
const chalk = require('chalk');

const values = [
    'blue' + chalk.bgBlue('berry'),
    '笔菠萝' + chalk.yellow('苹果笔'),
    chalk.red('apple'), 'pomegranate',
    'durian', chalk.green('star fruit'),
    'パイナップル', 'apricot', 'banana',
    'pineapple', chalk.bgRed.yellow('orange')
];

console.log(columns(values));
screenshot

API

columns(values [, options]): String

  • values {Array<String>} Array of strings to display.
  • options {Object}
    • character {String} (default: ' ') Padding character.
    • newline {String} (default: '\n') Newline character.
    • padding {Number} (default: 2) Space between columns.
    • sort {Boolean} (default: true) Whether to sort results.
    • width {Number} (default: process.stdout.columns) Max width of list.

Sorts and formats a list of values into columns suitable to display in a given width.

Contribute

Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.

Test

$ npm test

MIT © Shannon Moeller

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin