diff --git a/packages/cli-uwf/src/cli.ts b/packages/cli-uwf/src/cli.ts index 280dc25..9002cc1 100755 --- a/packages/cli-uwf/src/cli.ts +++ b/packages/cli-uwf/src/cli.ts @@ -40,7 +40,7 @@ function runAction(action: () => Promise): void { const program = new Command(); program.name("uwf").description("Stateless workflow CLI"); -program.option("--format ", "Output format: json, yaml, table", "json"); +program.option("--format ", "Output format: json or yaml", "json"); const workflow = program.command("workflow").description("Workflow registry and CAS"); diff --git a/packages/cli-uwf/src/format.ts b/packages/cli-uwf/src/format.ts index ff339f4..2c4b368 100644 --- a/packages/cli-uwf/src/format.ts +++ b/packages/cli-uwf/src/format.ts @@ -1,35 +1,6 @@ import { stringify } from "yaml"; -export type OutputFormat = "json" | "yaml" | "table"; - -function formatHorizontalTable(data: Array>): string { - if (data.length === 0) return ""; - const keys = Object.keys(data[0]); - const widths = keys.map((k) => { - let max = k.length; - for (const row of data) { - const len = String(row[k] ?? "").length; - if (len > max) max = len; - } - return max; - }); - const header = keys.map((k, i) => k.toUpperCase().padEnd(widths[i])).join(" "); - const rows = data.map((row) => - keys.map((k, i) => String(row[k] ?? "").padEnd(widths[i])).join(" "), - ); - return [header, ...rows].join("\n"); -} - -function formatVerticalTable(data: Record): string { - const entries = Object.entries(data); - if (entries.length === 0) return ""; - const keyWidth = Math.max(...entries.map(([k]) => k.length)); - const header = `${"KEY".padEnd(keyWidth)} VALUE`; - const rows = entries.map( - ([k, v]) => `${k.padEnd(keyWidth)} ${typeof v === "object" ? JSON.stringify(v) : String(v)}`, - ); - return [header, ...rows].join("\n"); -} +export type OutputFormat = "json" | "yaml"; export function formatOutput(data: unknown, format: OutputFormat): string { switch (format) { @@ -37,18 +8,5 @@ export function formatOutput(data: unknown, format: OutputFormat): string { return JSON.stringify(data); case "yaml": return stringify(data).trimEnd(); - case "table": - if ( - Array.isArray(data) && - data.length > 0 && - typeof data[0] === "object" && - data[0] !== null - ) { - return formatHorizontalTable(data as Array>); - } - if (typeof data === "object" && data !== null && !Array.isArray(data)) { - return formatVerticalTable(data as Record); - } - return stringify(data).trimEnd(); } }