(output: FormattedOutput<FormattedPrintable>)
| 84 | } |
| 85 | |
| 86 | function stringifyFormattedOutput(output: FormattedOutput<FormattedPrintable>): string { |
| 87 | switch (output.format) { |
| 88 | case '': |
| 89 | case OutputFormat.TEXT: |
| 90 | return output.data.text() |
| 91 | case OutputFormat.JSON: |
| 92 | return `${JSON.stringify(output.data.json(), null, 2)}\n` |
| 93 | case OutputFormat.YAML: |
| 94 | return yaml.dump(output.data.json(), { indent: 2, lineWidth: -1 }) |
| 95 | case OutputFormat.NAME: |
| 96 | return `${toName(output.data)}\n` |
| 97 | default: |
| 98 | throw new OutputFormatNotSupportedError(output.format) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | function stringifyTableOutput(output: TableOutput<TablePrintable>): string { |
| 103 | switch (output.format) { |
no test coverage detected