Files
HackBrowserData/internal/app/report.go
T
Roger 9e9d1c531d refactor: rename identifiers and expand the browser table (#685)
Names say what each thing is: no package stutter, one word per concept, spelled out, none that differ only in case.
The browser table puts one field per line. Wire names (flags, output fields, keys.json) are unchanged.
2026-11-09 17:25:35 +08:00

36 lines
919 B
Go

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