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'] });"
FunctionCategoryPurpose
formatTable(rows, options) / printTable(rows, options)TablesMeasure and render an aligned table string or write it to stdout.
measureColumns(grids, options) / renderGrid(rows, options)Shared gridsShare column widths and caps across multiple table sections.
measureDecimalPlaces(grids)Decimal alignShare fractional digit slots across decimal-aligned table sections.
escapeCell(value)SanitizationEscape tabs, newlines, ANSI sequences, and control characters for safe cells.
formatCount / formatDuration / formatPercent / formatBarScalarsFormat compact counts (960K), durations (2h 5m), percentages (16%), and bars.
formatRelativeTime / formatTimer / formatClock / formatLocalTimestampTimeFormat 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'],
});

Documentation pages

Source repository and releases