From f97d236951af0ed82854e25319ff35542c04a010 Mon Sep 17 00:00:00 2001 From: Lu Jingxiao Date: Thu, 4 Feb 2021 20:04:01 +0800 Subject: [PATCH] update images display --- cmd/cli/images.go | 1 + vendor/github.com/bndr/gotabulate/tabulate.go | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmd/cli/images.go b/cmd/cli/images.go index bded3617..0405a34b 100644 --- a/cmd/cli/images.go +++ b/cmd/cli/images.go @@ -100,5 +100,6 @@ func formatAndPrint(images []*pb.ListResponse_ImageInfo) { tabulate := gotabulate.Create(lines) tabulate.SetHeaders(title) tabulate.SetAlign("left") + tabulate.SetDenseMode(true) fmt.Print(tabulate.Render("simple")) } diff --git a/vendor/github.com/bndr/gotabulate/tabulate.go b/vendor/github.com/bndr/gotabulate/tabulate.go index a2e43265..095c11d8 100644 --- a/vendor/github.com/bndr/gotabulate/tabulate.go +++ b/vendor/github.com/bndr/gotabulate/tabulate.go @@ -1,10 +1,13 @@ package gotabulate -import "fmt" -import "bytes" -import "github.com/mattn/go-runewidth" -import "unicode/utf8" -import "math" +import ( + "bytes" + "fmt" + "math" + "unicode/utf8" + + "github.com/mattn/go-runewidth" +) // Basic Structure of TableFormat type TableFormat struct { @@ -84,6 +87,7 @@ type Tabulate struct { WrapStrings bool WrapDelimiter rune SplitConcat string + DenseMode bool } // Represents normalized tabulate Row @@ -208,6 +212,10 @@ func (t *Tabulate) SetWrapDelimiter(r rune) { t.WrapDelimiter = r } +func (t *Tabulate) SetDenseMode(m bool) { + t.DenseMode = m +} + //SetSplitConcat assigns the character that will be used when a WrapDelimiter is //set but the renderer cannot abide by the desired split. This may happen when //the WrapDelimiter is a space ' ' but a single word is longer than the width of a cell @@ -292,7 +300,7 @@ func (t *Tabulate) Render(format ...interface{}) string { // Add Data Rows for index, element := range t.Data { lines = append(lines, t.buildRow(t.padRow(element.Elements, t.TableFormat.Padding), padded_widths, cols, t.TableFormat.DataRow)) - if index < len(t.Data)-1 { + if !t.DenseMode && index < len(t.Data)-1 { if element.Continuos != true && !inSlice("betweenLine", t.HideLines) { lines = append(lines, t.buildLine(padded_widths, cols, t.TableFormat.LineBetweenRows)) } -- 2.23.0