lmformat
lmformat (@lmctl-ai/lmformat) is a dependency-free Node.js library for CLI output formatting: automatically sized tables, counts, durations, and timestamps.
Quick reference
npm install @lmctl-ai/lmformat
node -e "const { printTable } = require('@lmctl-ai/lmformat'); printTable([['triage', 5, '25s']], { headers: ['team', 'msgs', 'time'] });"
| Function | Category | Purpose |
|---|---|---|
| formatTable(rows, options) / printTable(rows, options) | Tables | Measure and render an aligned table string or write it to stdout. |
| measureColumns(grids, options) / renderGrid(rows, options) | Shared grids | Share column widths and caps across multiple table sections. |
| measureDecimalPlaces(grids) | Decimal align | Share fractional digit slots across decimal-aligned table sections. |
| escapeCell(value) | Sanitization | Escape tabs, newlines, ANSI sequences, and control characters for safe cells. |
| formatCount / formatDuration / formatPercent / formatBar | Scalars | Format compact counts (960K), durations (2h 5m), percentages (16%), and bars. |
| formatRelativeTime / formatTimer / formatClock / formatLocalTimestamp | Time | Format relative ages/countdowns (3d ago), timers (00:36:12), and local clocks. |
const { printTable } = require('@lmctl-ai/lmformat');
const rows = [
['triage.lmctl', 'Triage', 'done', 5, '25s'],
['math.lmctl', 'Lead', 'done', 120, '2s'],
];
printTable(rows, {
headers: ['team', 'alias', 'status', 'msgs', 'time spent'],
align: ['left', 'left', 'left', 'right', 'right'],
});