(flagValue?: string)
| 4 | export type OutputFormat = 'text' | 'json'; |
| 5 | |
| 6 | export function detectOutputFormat(flagValue?: string): OutputFormat { |
| 7 | if (flagValue === 'json' || flagValue === 'text') { |
| 8 | return flagValue; |
| 9 | } |
| 10 | if (!process.stdout.isTTY) { |
| 11 | return 'json'; |
| 12 | } |
| 13 | return 'text'; |
| 14 | } |
| 15 | |
| 16 | export function formatOutput(data: unknown, format: OutputFormat): string { |
| 17 | switch (format) { |