From e1e57c8480865d432fd99fea7458fcfe96fc0ad5 Mon Sep 17 00:00:00 2001 From: mateon1 Date: Sun, 1 Jan 2017 18:56:34 +0000 Subject: [PATCH] Fix inconsistent ipfs stat bw formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Mateusz Naƛciszewski --- core/commands/stat.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/commands/stat.go b/core/commands/stat.go index ae5a7c7b88e..4cfea2df8d7 100644 --- a/core/commands/stat.go +++ b/core/commands/stat.go @@ -193,14 +193,15 @@ Example: printStats(out, bs) } else { if first { - fmt.Fprintln(out, "Total Up\t Total Down\t Rate Up\t Rate Down") + fmt.Fprintln(out, "Total Up Total Down Rate Up Rate Down") first = false } fmt.Fprint(out, "\r") - fmt.Fprintf(out, "%s \t\t", humanize.Bytes(uint64(bs.TotalOut))) - fmt.Fprintf(out, " %s \t\t", humanize.Bytes(uint64(bs.TotalIn))) - fmt.Fprintf(out, " %s/s \t", humanize.Bytes(uint64(bs.RateOut))) - fmt.Fprintf(out, " %s/s ", humanize.Bytes(uint64(bs.RateIn))) + // In the worst case scenario, the humanized output is of form "xxx.x xB", which is 8 characters long + fmt.Fprintf(out, "%8s ", humanize.Bytes(uint64(bs.TotalOut))) + fmt.Fprintf(out, "%8s ", humanize.Bytes(uint64(bs.TotalIn))) + fmt.Fprintf(out, "%8s/s ", humanize.Bytes(uint64(bs.RateOut))) + fmt.Fprintf(out, "%8s/s ", humanize.Bytes(uint64(bs.RateIn))) } return out, nil