Skip to content

Commit

Permalink
Improve text printer output
Browse files Browse the repository at this point in the history
With this commit, the fetch duration time is rounded to milliseconds to
provide sensible output to humans.

Also, a duration carries "skipped" - which makes printing "fetched in 0s"
a false statement. For now, **cciu** prints "skipped".
  • Loading branch information
mgumz committed Mar 11, 2023
1 parent 1d0f406 commit 8958e25
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/printer/text_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ func (p *TextPrinter) SetShowStats(s bool) {
// NewSpec starts printing the tags for "name" - its like a headline
func (p *TextPrinter) NewSpec(name string, dur time.Duration, err error) {
p.printedTag = false
fmt.Fprintln(p.w, name, fmt.Sprintf("# fetched in %s", dur))
comment := "# skipped"
if dur > 0 {
comment = fmt.Sprintf("# fetched in %s", dur.Round(time.Millisecond))
}
fmt.Fprintln(p.w, name, comment)
if err != nil {
fmt.Fprintf(p.w, "\t%s", err)
fmt.Fprintf(p.w, "\t%s\n", err)
return
}
}
Expand Down

0 comments on commit 8958e25

Please sign in to comment.