mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
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.
36 lines
919 B
Go
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 ""
|
|
}
|
|
}
|