mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-14 06:47:28 +00:00
Scaffold LogicSRC and CommandBoard plugins
This commit is contained in:
parent
59927e140c
commit
5c9ea821f6
67 changed files with 5958 additions and 0 deletions
22
packages/cli/src/format.ts
Normal file
22
packages/cli/src/format.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
export type OutputFormat = "json" | "table" | "markdown";
|
||||
|
||||
export function print(data: unknown, format: OutputFormat) {
|
||||
if (format === "json") {
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
return;
|
||||
}
|
||||
|
||||
if (format === "markdown") {
|
||||
if (Array.isArray(data)) {
|
||||
for (const item of data) {
|
||||
console.log(`- ${Object.entries(item as Record<string, unknown>).map(([key, value]) => `**${key}:** ${String(value)}`).join(", ")}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(Object.entries(data as Record<string, unknown>).map(([key, value]) => `**${key}:** ${String(value)}`).join("\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
console.table(data);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue