Files
HackBrowserData/internal/app/report.go
T
Roger 0ed920f846 docs: trim code comments to the why (#676)
Comments that restated names or narrated the code are gone, and multi-line ones are cut to a line of why.
Only comments change: each edited Go file has the same token stream as before. winapi and abe come later.
2026-11-02 00:03:03 +08:00

36 lines
776 B
Go

package app
import (
"fmt"
"io"
"text/tabwriter"
)
// The summary is not part of the output contract and never changes the exit status.
func Report(w io.Writer, s Summary) error {
tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0)
fmt.Fprintln(tw, "Browser\tProfile\tCategory\tResult\tRecords\tDetail")
for _, r := range s.Results {
profile, cat := "-", "-"
if r.Profile != "" {
profile = r.Profile
}
if r.Category != 0 {
cat = r.Category.String()
}
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%d\t%s\n", r.DirID, profile, cat, r.Outcome, r.Count, detail(r))
}
return tw.Flush()
}
func detail(r Result) string {
switch {
case r.Err != nil:
return r.Err.Error()
case r.Failed > 0:
return fmt.Sprintf("%d not recovered", r.Failed)
default:
return ""
}
}