From 4e7e9b64e3cf469b080d1afb1306964f2debd8f0 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Sun, 14 Oct 2018 11:04:11 -0400 Subject: [PATCH] dont show inefficiencies breakdown when there are none --- ui/detailsview.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/detailsview.go b/ui/detailsview.go index 61a542d..9cac387 100644 --- a/ui/detailsview.go +++ b/ui/detailsview.go @@ -73,15 +73,20 @@ func (view *DetailsView) Render() error { var wastedSpace int64 template := "%5s %12s %-s\n" + var trueInefficiencies int inefficiencyReport := fmt.Sprintf(Formatting.Header(template), "Count", "Total Space", "Path") for idx := len(view.inefficiencies)-1; idx > 0; idx-- { data := view.inefficiencies[idx] if data.CumulativeSize == 0 { continue } + trueInefficiencies++ wastedSpace += data.CumulativeSize inefficiencyReport += fmt.Sprintf(template, strconv.Itoa(len(data.Nodes)), humanize.Bytes(uint64(data.CumulativeSize)), data.Path) } + if trueInefficiencies == 0 { + inefficiencyReport = "" + } effStr := fmt.Sprintf("\n%s %d %%", Formatting.Header("Image efficiency score:"), int(100.0*view.efficiency)) spaceStr := fmt.Sprintf("%s %s\n", Formatting.Header("Potential wasted space:"), humanize.Bytes(uint64(wastedSpace)))