https://github.com/perry-mitchell/colm
Column formatter for terminal applications
https://github.com/perry-mitchell/colm
column columns command-line formatter stdout
Last synced: 24 days ago
JSON representation
Column formatter for terminal applications
- Host: GitHub
- URL: https://github.com/perry-mitchell/colm
- Owner: perry-mitchell
- License: mit
- Created: 2017-06-09T15:40:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T19:47:01.000Z (almost 9 years ago)
- Last Synced: 2025-10-03T15:41:10.129Z (5 months ago)
- Topics: column, columns, command-line, formatter, stdout
- Language: JavaScript
- Size: 43.9 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# colm
Column formatter for terminal applications _(Pronouced "column")_
[](https://travis-ci.org/perry-mitchell/colm) [](https://www.npmjs.com/package/colm)
## About
`colm` is a column formatter for text designed to be written to standard-out in the terminal. It came to be in light of too few options to format and align columns of text in the terminal.
## Usage
`colm` takes an array of arrays: a group of _rows_. Each row is expected to be an array of strings, which are mapped to columns. `colm` will try to adjust column widths automatically so that the text fits perfectly in the terminal, but these can be overidden.
```javascript
const formatColumns = require("colm");
const { bold } = require("chalk"); // colours and styles
console.log(formatColums([
["NodeJS Version", "Supports Destructuring", "Released"].map(bold),
["8.x", "Yes", "2017-05-30"],
["7.x", "Yes", "2016-10-25"],
["6.x", "Yes", "2016-04-26"],
["5.x", "No", "2015-10-29"],
["4.x", "No", "2015-09-08"]
]));
```
This example results in the following table:

### Parameters and options
```javascript
formatColumns(data, options);
```
`options` is made up of the following optional properties:
* `termWidth`: Width of the terminal (override) (columns)
* `columnWidths`: Array of numbers representing column width overrides (all columns required if specified)