summaryrefslogtreecommitdiffstats
path: root/helpers/processing_stats.go
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/processing_stats.go')
-rw-r--r--helpers/processing_stats.go44
1 files changed, 21 insertions, 23 deletions
diff --git a/helpers/processing_stats.go b/helpers/processing_stats.go
index 3f48466c7..42376b46d 100644
--- a/helpers/processing_stats.go
+++ b/helpers/processing_stats.go
@@ -19,6 +19,8 @@ import (
"sync/atomic"
"github.com/olekukonko/tablewriter"
+ "github.com/olekukonko/tablewriter/renderer"
+ "github.com/olekukonko/tablewriter/tw"
)
// ProcessingStats represents statistics about a site build.
@@ -66,23 +68,6 @@ func (s *ProcessingStats) Add(counter *uint64, amount int) {
atomic.AddUint64(counter, uint64(amount))
}
-// Table writes a table-formatted representation of the stats in a
-// ProcessingStats instance to w.
-func (s *ProcessingStats) Table(w io.Writer) {
- titleVals := s.toVals()
- data := make([][]string, len(titleVals))
- for i, tv := range titleVals {
- data[i] = []string{tv.name, strconv.Itoa(int(tv.val))}
- }
-
- table := tablewriter.NewWriter(w)
-
- table.AppendBulk(data)
- table.SetHeader([]string{"", s.Name})
- table.SetBorder(false)
- table.Render()
-}
-
// ProcessingStatsTable writes a table-formatted representation of stats to w.
func ProcessingStatsTable(w io.Writer, stats ...*ProcessingStats) {
names := make([]string, len(stats)+1)
@@ -106,13 +91,26 @@ func ProcessingStatsTable(w io.Writer, stats ...*ProcessingStats) {
data[j] = append(data[j], strconv.Itoa(int(tv.val)))
}
}
-
}
- table := tablewriter.NewWriter(w)
-
- table.AppendBulk(data)
- table.SetHeader(names)
- table.SetBorder(false)
+ table := tablewriter.NewTable(
+ w,
+ tablewriter.WithRenderer(renderer.NewBlueprint(tw.Rendition{
+ Borders: tw.BorderNone,
+ Symbols: tw.NewSymbols(tw.StyleLight),
+ Settings: tw.Settings{
+ Separators: tw.Separators{BetweenRows: tw.Off},
+ Lines: tw.Lines{ShowFooterLine: tw.On},
+ },
+ })),
+ tablewriter.WithConfig(
+ tablewriter.Config{
+ MaxWidth: 70,
+ Row: tw.CellConfig{Alignment: tw.CellAlignment{Global: tw.AlignRight, PerColumn: []tw.Align{tw.AlignLeft}}},
+ }),
+ )
+
+ table.Bulk(data)
+ table.Header(names)
table.Render()
}