From dd83f6bc685426e46d7e1ffaec31c5a36d7e2f75 Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 4 Nov 2020 14:36:42 -0600 Subject: [PATCH] Cleanup formatter --- command/snapshot/inspect/formatter.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/command/snapshot/inspect/formatter.go b/command/snapshot/inspect/formatter.go index 89a3c368f..8dd02f612 100644 --- a/command/snapshot/inspect/formatter.go +++ b/command/snapshot/inspect/formatter.go @@ -57,26 +57,20 @@ func (_ *prettyFormatter) Format(info *OutputFormat, detailed bool) (string, err fmt.Fprintf(tw, "\n %s\t%s\t%s\t", "----", "----", "----") fmt.Fprintf(tw, "\n Total\t\t%s\t", ByteSize(uint64(info.TotalSize))) - if err := tw.Flush(); err != nil { - return b.String(), err - } - if detailed { - kvtw := tabwriter.NewWriter(&b, 30, 8, 12, ' ', 0) - - fmt.Fprintf(kvtw, "\n") - fmt.Fprintln(kvtw, "\n Key Name\tCount\tSize\t") - fmt.Fprintf(kvtw, " %s\t%s\t%s\t", "----", "----", "----") + fmt.Fprintf(tw, "\n") + fmt.Fprintln(tw, "\n Key Name\tCount\tSize\t") + fmt.Fprintf(tw, " %s\t%s\t%s\t", "----", "----", "----") // For each different type generate new output for _, s := range info.KStats { - fmt.Fprintf(kvtw, "\n %s\t%d\t%s\t", s.Name, s.Count, ByteSize(uint64(s.Sum))) + fmt.Fprintf(tw, "\n %s\t%d\t%s\t", s.Name, s.Count, ByteSize(uint64(s.Sum))) } - fmt.Fprintf(kvtw, "\n %s\t%s\t%s\t", "----", "----", "----") - fmt.Fprintf(kvtw, "\n Total\t\t%s\t", ByteSize(uint64(info.TotalSize))) + fmt.Fprintf(tw, "\n %s\t%s\t%s\t", "----", "----", "----") + fmt.Fprintf(tw, "\n Total\t\t%s\t", ByteSize(uint64(info.TotalSize))) + } - if err := kvtw.Flush(); err != nil { - return b.String(), err - } + if err := tw.Flush(); err != nil { + return b.String(), err } return b.String(), nil