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

Method WriteAll

internal/input/report.go:129–155  ·  view source on GitHub ↗

WriteAll writes the report to all the given targets.

(targets []string, p format.TargetParser)

Source from the content-addressed store, hash-verified

127
128// WriteAll writes the report to all the given targets.
129func (r Report) WriteAll(targets []string, p format.TargetParser) (allErrors error) {
130 if len(targets) == 0 {
131 targets = append(targets, Text)
132 }
133 for _, targetName := range targets {
134 target, err := p.Parse(targetName)
135 if err != nil {
136 allErrors = errors.Join(allErrors, err)
137 continue
138 }
139
140 data, err := r.toFormat(target.Format)
141 if err != nil {
142 allErrors = errors.Join(allErrors, err)
143 continue
144 }
145
146 if !bytes.HasSuffix(data, []byte{'\n'}) {
147 data = append(data, "\n"...)
148 }
149
150 if _, err := target.Write(data); err != nil {
151 allErrors = errors.Join(allErrors, err)
152 }
153 }
154 return
155}
156
157// toFormat converts the report into the given format.
158func (r *Report) toFormat(format string) (data []byte, err error) {

Callers 2

WriteReportFunction · 0.95
validateInputCmdFunction · 0.95

Calls 3

toFormatMethod · 0.95
ParseMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected