UNPKG

zephyr-agent

Version:
40 lines (39 loc) • 1.36 kB
import "node:module"; import { bold, dim, gray, green, purple, yellow } from "./picocolor.mjs"; const INDENT = ' '; const toneAccent = { info: purple, warn: yellow, success: green, muted: gray }; const defaultTone = 'info'; const indentLine = (line)=>{ if (!line) return ''; return `${INDENT}${line}`; }; function renderSection(options) { const { title, subtitle, body = [], tone = defaultTone } = options; const accent = toneAccent[tone] ?? toneAccent[defaultTone]; const lines = []; if (title) lines.push(accent(bold(title))); if (subtitle) lines.push(indentLine(dim(subtitle))); if (body.length) lines.push(...body.filter((line)=>'string' == typeof line).map(indentLine)); return lines.join('\n'); } function renderKeyValueRows(rows) { if (!rows.length) return []; const maxLabelLength = Math.max(...rows.map(({ label })=>label.length)); return rows.map(({ label, value })=>{ const paddedLabel = label.padEnd(maxLabelLength, ' '); return `${gray(paddedLabel)} ${value}`; }); } function renderList(items) { return items.map((item)=>`- ${item}`); } function joinSections(sections) { return sections.filter((section)=>Boolean(section)).join('\n'); } export { joinSections, renderKeyValueRows, renderList, renderSection }; //# sourceMappingURL=cli-format.mjs.map