(argv: readonly string[])
| 116 | } |
| 117 | |
| 118 | export function sniffOutputFormat(argv: readonly string[]): string { |
| 119 | for (let i = 0; i < argv.length; i++) { |
| 120 | const t = argv[i] |
| 121 | if (t === undefined) |
| 122 | continue |
| 123 | if (t === '--') |
| 124 | return '' |
| 125 | |
| 126 | if (t === '--output' || t === '-o') { |
| 127 | const next = argv[i + 1] |
| 128 | if (next !== undefined && !next.startsWith('-')) |
| 129 | return next |
| 130 | continue |
| 131 | } |
| 132 | if (t.startsWith('--output=')) |
| 133 | return t.slice('--output='.length) |
| 134 | if (t.startsWith('-o=')) |
| 135 | return t.slice('-o='.length) |
| 136 | } |
| 137 | return '' |
| 138 | } |
| 139 | |
| 140 | function isStructuredFormat(format: string): boolean { |
| 141 | return format === 'json' || format === 'yaml' |
no test coverage detected