Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shannonmoeller/cli-columns
Columnated lists for the CLI. Unicode and ANSI safe.
https://github.com/shannonmoeller/cli-columns
cli column columnate columns nodejs
Last synced: 4 days ago
JSON representation
Columnated lists for the CLI. Unicode and ANSI safe.
- Host: GitHub
- URL: https://github.com/shannonmoeller/cli-columns
- Owner: shannonmoeller
- License: mit
- Created: 2016-02-13T22:09:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-11-03T05:40:01.000Z (about 3 years ago)
- Last Synced: 2025-01-14T09:09:44.079Z (12 days ago)
- Topics: cli, column, columnate, columns, nodejs
- Language: JavaScript
- Homepage: http://npm.im/cli-columns
- Size: 28.3 KB
- Stars: 34
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome-nodejs-cn - cli-columns - 列式输出 Unicode 和 Ansi-safe (包 / 命令行工具)
- awesome-nodejs-cn - cli-columns - **star:34** 列式unicode和ansi安全的文本列表 (包 / 命令行实用工具)
- awesome-nodejs - cli-columns - Columnated unicode and ansi-safe text lists. (Packages / Command-line utilities)
- awesome-nodejs - cli-columns - Columnated lists for the CLI. Unicode and ANSI safe. - ★ 14 (Command-line utilities)
- awesome-node - cli-columns - Columnated unicode and ansi-safe text lists. (Packages / Command-line utilities)
- awesome-nodejs-cn - cli-columns - 列式Unicode和Ansi安全文本列表. (目录 / 命令行工具)
README
# `cli-columns`
[![NPM version][npm-img]][npm-url] [![Downloads][downloads-img]][npm-url]
Columnated lists for the CLI. Unicode and ANSI safe.
## Install
$ npm install --save cli-columns
## Usage
```js
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));
```## API
### columns(values [, options]): String
- `values` `{Array}` 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](http://shannonmoeller.com)
[downloads-img]: http://img.shields.io/npm/dm/cli-columns.svg?style=flat-square
[npm-img]: http://img.shields.io/npm/v/cli-columns.svg?style=flat-square
[npm-url]: https://npmjs.org/package/cli-columns