6eace09826
Table format adds complexity without readability gain over yaml. Refs #328
13 lines
291 B
TypeScript
13 lines
291 B
TypeScript
import { stringify } from "yaml";
|
|
|
|
export type OutputFormat = "json" | "yaml";
|
|
|
|
export function formatOutput(data: unknown, format: OutputFormat): string {
|
|
switch (format) {
|
|
case "json":
|
|
return JSON.stringify(data);
|
|
case "yaml":
|
|
return stringify(data).trimEnd();
|
|
}
|
|
}
|