MCPcopy Create free account
hub / github.com/conforma/cli / WriteAll

Method WriteAll

cmd/validate/vsa.go:1300–1319  ·  view source on GitHub ↗

WriteAll writes ComponentResultsDisplay to all specified output formats

(outputFormats []string, fs afero.Fs, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

1298
1299// WriteAll writes ComponentResultsDisplay to all specified output formats
1300func (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"

Callers 2

captureFallbackTextFunction · 0.45

Calls 4

toFormatMethod · 0.95
parseOutputSpecFunction · 0.85
writeDataToOutputFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected