MCPcopy Index your code
hub / github.com/MiniMax-AI/cli / formatTable

Function formatTable

src/output/text.ts:47–62  ·  view source on GitHub ↗
(rows: Record<string, unknown>[])

Source from the content-addressed store, hash-verified

45}
46
47export function formatTable(rows: Record<string, unknown>[]): string {
48 if (rows.length === 0) return '(empty)';
49
50 const keys = Object.keys(rows[0]!);
51 const widths = keys.map(k =>
52 Math.max(k.length, ...rows.map(r => String(r[k] ?? '').length)),
53 );
54
55 const header = keys.map((k, i) => k.toUpperCase().padEnd(widths[i]!)).join(' ');
56 const separator = widths.map(w => '-'.repeat(w)).join(' ');
57 const body = rows.map(r =>
58 keys.map((k, i) => String(r[k] ?? '').padEnd(widths[i]!)).join(' '),
59 );
60
61 return [header, separator, ...body].join('\n');
62}

Callers 2

runFunction · 0.85
formatTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected