Skip to content

Commit fd4d261

Browse files
committed
style: use Transformer comma separate
1 parent d6a5f63 commit fd4d261

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,23 @@ func printTable(languages Languages) {
246246
{
247247
Name: "Lines",
248248
Align: text.AlignRight,
249+
Transformer: func(val interface{}) string {
250+
return p.Sprintf("%d", val)
251+
},
252+
TransformerFooter: func(val interface{}) string {
253+
return p.Sprintf("%d", val)
254+
},
249255
},
250256
})
251257

252258
// Append rows in sorted order
259+
sumLines := 0
253260
for _, pair := range pairs {
254-
num := p.Sprintf("%d", pair.Value)
255-
t.AppendRow(table.Row{pair.Key, num})
261+
sumLines += pair.Value
262+
t.AppendRow(table.Row{pair.Key, pair.Value})
256263
}
264+
265+
t.AppendFooter(table.Row{"Total", sumLines})
257266
t.Render()
258267
}
259268

0 commit comments

Comments
 (0)