WriteReport writes a brief summary to the provided writer
(out io.Writer)
| 43 | |
| 44 | // WriteReport writes a brief summary to the provided writer |
| 45 | func (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 | } |
nothing calls this directly
no test coverage detected