WriteAll writes ComponentResultsDisplay to all specified output formats
(outputFormats []string, fs afero.Fs, cmd *cobra.Command)
| 1298 | |
| 1299 | // WriteAll writes ComponentResultsDisplay to all specified output formats |
| 1300 | func (d ComponentResultsDisplay) WriteAll(outputFormats []string, fs afero.Fs, cmd *cobra.Command) error { |
| 1301 | if len(outputFormats) == 0 { |
| 1302 | outputFormats = []string{outputFormatText} |
| 1303 | } |
| 1304 | |
| 1305 | for _, outputSpec := range outputFormats { |
| 1306 | formatName, file := parseOutputSpec(outputSpec) |
| 1307 | |
| 1308 | data, err := d.toFormat(formatName) |
| 1309 | if err != nil { |
| 1310 | return fmt.Errorf("failed to convert to %s: %w", formatName, err) |
| 1311 | } |
| 1312 | |
| 1313 | if err := writeDataToOutput(data, formatName, file, fs, cmd); err != nil { |
| 1314 | return err |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | return nil |
| 1319 | } |
| 1320 | |
| 1321 | // parseOutputSpec parses an output specification string into format name and file path |
| 1322 | // Format: "format" or "format=file" |
no test coverage detected