Fix inconsistent ipfs stat bw formatting
License: MIT Signed-off-by: Mateusz Naściszewski <matin1111@wp.pl>
mateon1 committed
Jan 1, 2017 at 18:56 UTC
e1e57c8480865d432fd99fea7458fcfe96fc0ad5
1 file changed
+6
-5
core/commands/stat.go
+6
-5
@@ -193,14 +193,15 @@ Example:
193
printStats(out, bs)
194
} else {
195
if first {
196
- fmt.Fprintln(out, "Total Up\t Total Down\t Rate Up\t Rate Down")
196
+ fmt.Fprintln(out, "Total Up Total Down Rate Up Rate Down")
197
first = false
198
}
199
fmt.Fprint(out, "\r")
200
- fmt.Fprintf(out, "%s \t\t", humanize.Bytes(uint64(bs.TotalOut)))
201
- fmt.Fprintf(out, " %s \t\t", humanize.Bytes(uint64(bs.TotalIn)))
202
- fmt.Fprintf(out, " %s/s \t", humanize.Bytes(uint64(bs.RateOut)))
203
- fmt.Fprintf(out, " %s/s ", humanize.Bytes(uint64(bs.RateIn)))
200
+ // In the worst case scenario, the humanized output is of form "xxx.x xB", which is 8 characters long
201
+ fmt.Fprintf(out, "%8s ", humanize.Bytes(uint64(bs.TotalOut)))
202
+ fmt.Fprintf(out, "%8s ", humanize.Bytes(uint64(bs.TotalIn)))
203
+ fmt.Fprintf(out, "%8s/s ", humanize.Bytes(uint64(bs.RateOut)))
204
+ fmt.Fprintf(out, "%8s/s ", humanize.Bytes(uint64(bs.RateIn)))
205
}
206
return out, nil
207