Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
cli-columns
Advanced tools
The cli-columns npm package is a utility for formatting text into columns for command-line interfaces. It helps in organizing and displaying data in a tabular format, making it easier to read and understand.
Basic Column Formatting
This feature allows you to format an array of strings into columns. The code sample demonstrates how to use the cli-columns package to display a list of items in a columnar format.
const columns = require('cli-columns');
const data = ['Name', 'Age', 'Occupation', 'Location'];
console.log(columns(data));
Custom Column Width
This feature allows you to specify a custom width for the columns. The code sample shows how to set the column width to 20 characters.
const columns = require('cli-columns');
const data = ['Name', 'Age', 'Occupation', 'Location'];
console.log(columns(data, { width: 20 }));
Column Padding
This feature allows you to add padding between columns. The code sample demonstrates how to add 2 spaces of padding between each column.
const columns = require('cli-columns');
const data = ['Name', 'Age', 'Occupation', 'Location'];
console.log(columns(data, { padding: 2 }));
The columnify package is another utility for formatting text into columns. It offers more customization options such as column alignment, data transformation, and custom column headers. Compared to cli-columns, columnify provides more advanced features for complex data formatting.
The cli-table package is a popular choice for creating tables in the command line. It supports features like text wrapping, custom table styles, and nested tables. While cli-columns focuses on simple column formatting, cli-table offers a more comprehensive solution for creating detailed tables.
The easy-table package is designed for creating ASCII tables in the command line. It provides features like column alignment, table sorting, and custom cell formatting. Compared to cli-columns, easy-table is more suited for creating structured tables with various formatting options.
cli-columns
Columnated lists for the CLI. Unicode and ANSI safe.
$ npm install --save cli-columns
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));
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.
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.
$ npm test
MIT © Shannon Moeller
FAQs
Columnated lists for the CLI.
The npm package cli-columns receives a total of 516,889 weekly downloads. As such, cli-columns popularity was classified as popular.
We found that cli-columns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.