| name | cli-table-formatter |
| description | Generate table formatters for structured CLI output with column alignment, borders, and responsive sizing. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
| graph | {"domains":["domain:software-engineering"],"specializations":["specialization:cli-mcp-development"],"skillAreas":["skill-area:cli-design","skill-area:command-line-interface-tools"],"roles":["role:backend-engineer","role:platform-engineer"],"workflows":["workflow:feature-development"],"topics":["topic:developer-experience","topic:responsive-design"]} |
CLI Table Formatter
Generate table formatters for structured CLI output.
Capabilities
- Create table formatters with various styles
- Configure column alignment and width
- Implement responsive table sizing
- Support Unicode borders
- Handle multiline cells
- Generate table utilities
Usage
Invoke this skill when you need to:
- Display tabular data in CLI
- Create formatted list output
- Configure column widths
- Support various border styles
Inputs
| Parameter | Type | Required | Description |
|---|
| language | string | Yes | Target language |
| style | string | No | Border style (simple, unicode, markdown) |
| features | array | No | Required features |
Generated Patterns
TypeScript Table Formatter
import chalk from 'chalk';
export interface TableColumn {
key: string;
header: string;
width?: number;
align?: 'left' | 'center' | 'right';
format?: (value: any) => string;
}
export interface TableOptions {
columns: TableColumn[];
borderStyle?: 'simple' | 'unicode' | 'none' | 'markdown';
headerColor?: (text: string) => string;
maxWidth?: number;
}
const borders = {
simple: {
top: '-', bottom: '-', left: '|', right: '|',
topLeft: '+', topRight: '+', bottomLeft: '+', bottomRight: ,
: , : , : ,
},
: {
: , : , : , : ,
: , : , : , : ,
: , : , : ,
: , : , : , : ,
},
: {
: , : , : , : ,
: , : , : , : ,
: , : , : ,
},
};
{
: [];
: ;
: borders.;
() {
. = options;
. = options.;
. = borders[options. || ];
}
(: <, >[]): [] {
..( {
headerWidth = col..;
maxDataWidth = .(
...data.( (row[col.] ?? ).)
);
col. || .(headerWidth, maxDataWidth);
});
}
(: , : , : | | = ): {
padding = width - text.;
(align === ) {
left = .(padding / );
right = padding - left;
.(left) + text + .(right);
}
(align === ) {
.(padding) + text;
}
text + .(padding);
}
(: <, >[]): {
widths = .(data);
: [] = [];
b = .;
(b.) {
lines.(
b. +
widths.( b..(w + )).(b. || b.) +
b.
);
}
headerCells = ..(
+ .(col., widths[i], col.) +
);
headerColor = .. || chalk.;
lines.(
b. +
headerCells.( (c)).(b.) +
b.
);
(b.) {
lines.(
(b. || b.) +
widths.( b..(w + )).(b.) +
(b. || b.)
);
}
( row data) {
cells = ..( {
value = row[col.] ?? ;
formatted = col. ? col.(value) : (value);
+ .(formatted, widths[i], col.) + ;
});
lines.(b. + cells.(b.) + b.);
}
(b.) {
lines.(
b. +
widths.( b..(w + )).(b. || b.) +
b.
);
}
lines.();
}
}
(): {
: [] = columns
? columns.( c === ? { : c, : c } : c)
: .(data[] || {}).( ({ key, : key }));
({ : cols }).(data);
}
Usage Examples
console.log(table([
{ name: 'Alice', age: 30, role: 'Admin' },
{ name: 'Bob', age: 25, role: 'User' },
]));
const formatter = new TableFormatter({
columns: [
{ key: 'id', header: 'ID', width: 6, align: 'right' },
{ key: 'name', header: 'Name', width: 20 },
{ key: 'status', header: 'Status', format: (v) =>
v === 'active' ? chalk.green(v) : chalk.red(v)
},
],
borderStyle: 'unicode',
headerColor: chalk.cyan.bold,
});
console.log(formatter.format(data));
Dependencies
{
"dependencies": {
"chalk": "^5.0.0"
}
}
Target Processes
- cli-output-formatting
- dashboard-monitoring-tui
- cli-application-bootstrap