MCPcopy
hub / github.com/homeport/dyff / WriteReport

Method WriteReport

pkg/dyff/output_brief.go:45–67  ·  view source on GitHub ↗

WriteReport writes a brief summary to the provided writer

(out io.Writer)

Source from the content-addressed store, hash-verified

43
44// WriteReport writes a brief summary to the provided writer
45func (report *BriefReport) WriteReport(out io.Writer) error {
46 writer := bufio.NewWriter(out)
47 defer func() { _ = writer.Flush() }()
48
49 noOfChanges := bunt.Style(text.Plural(len(report.Diffs), "change"), bunt.Bold())
50 niceFrom := ytbx.HumanReadableLocationInformation(report.From)
51 niceTo := ytbx.HumanReadableLocationInformation(report.To)
52
53 var template string
54 switch {
55 case len(oneline)-6+plainTextLength(noOfChanges)+plainTextLength(niceFrom)+plainTextLength(niceTo) < term.GetTerminalWidth():
56 template = oneline
57
58 default:
59 template = twoline
60 }
61
62 _, _ = fmt.Fprintf(writer, template, noOfChanges, niceFrom, niceTo)
63
64 // Finish with one last newline so that we do not end next to the prompt
65 _, _ = writer.WriteString("\n")
66 return nil
67}

Callers

nothing calls this directly

Calls 3

plainTextLengthFunction · 0.85
WriteStringMethod · 0.80
BoldMethod · 0.65

Tested by

no test coverage detected