Print the byte unit once in the summary line (closes #17)
check / check (push) Successful in 3m2s
check / check (push) Successful in 3m2s
formatBytes already ends in a unit, so the summary line read "9 B bytes" or "1.0 KiB bytes". The format string in Stats.Print no longer adds the word "bytes". Print now takes the io.Writer to print to; its callers pass os.Stderr, and the new test passes a buffer to read the line for one small and one large byte count. Model: opus-5-5
This commit is contained in:
+6
-6
@@ -71,13 +71,13 @@ func (s *Stats) Duration() time.Duration {
|
||||
return time.Since(s.StartTime)
|
||||
}
|
||||
|
||||
func (s *Stats) Print(opts *options, operation string) {
|
||||
func (s *Stats) Print(w io.Writer, opts *options, operation string) {
|
||||
if opts.quiet {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr,
|
||||
"\n%s complete: %d files processed, %d skipped, %d failed, %s bytes in %s\n",
|
||||
_, _ = fmt.Fprintf(w,
|
||||
"\n%s complete: %d files processed, %d skipped, %d failed, %s in %s\n",
|
||||
operation,
|
||||
s.FilesProcessed,
|
||||
s.FilesSkipped,
|
||||
@@ -227,7 +227,7 @@ func runOverPaths(
|
||||
}
|
||||
|
||||
finishBar(bar)
|
||||
stats.Print(opts, op)
|
||||
stats.Print(os.Stderr, opts, op)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -481,7 +481,7 @@ func runCheck(opts *options, args []string, cont bool) error {
|
||||
if perr != nil {
|
||||
if !cont {
|
||||
finishBar(bar)
|
||||
stats.Print(opts, "check")
|
||||
stats.Print(os.Stderr, opts, "check")
|
||||
|
||||
return perr
|
||||
}
|
||||
@@ -491,7 +491,7 @@ func runCheck(opts *options, args []string, cont bool) error {
|
||||
}
|
||||
|
||||
finishBar(bar)
|
||||
stats.Print(opts, "check")
|
||||
stats.Print(os.Stderr, opts, "check")
|
||||
|
||||
return finalErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user