From e38c2ef1e4dc0f7579027deb7c36cba2516e8161 Mon Sep 17 00:00:00 2001 From: DCCooper <1866858@gmail.com> Date: Wed, 10 Feb 2021 10:09:31 +0800 Subject: [PATCH 1/2] vendor:update tabulate vendor to support eliminate space line Signed-off-by: DCCooper <1866858@gmail.com> --- go.mod | 2 +- go.sum | 4 +-- vendor/github.com/bndr/gotabulate/tabulate.go | 25 +++++++++++++------ vendor/modules.txt | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 336dd2cc..b02071c9 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 github.com/blang/semver v4.0.0+incompatible // indirect - github.com/bndr/gotabulate v1.1.3-0.20170315142410-bc555436bfd5 + github.com/bndr/gotabulate v1.1.3-0.20210209140214-21a495b00e22 github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340 // indirect github.com/containerd/containerd v1.4.0-rc.0 github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe // indirect diff --git a/go.sum b/go.sum index 1ecfa084..3a52a22f 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/blang/semver v4.0.0+incompatible h1:hnDL+Ci6ZJmEDIbUvCUt3Gh3QsnkdiIj88cWsqe4C4I= github.com/blang/semver v4.0.0+incompatible/go.mod h1:u4Z/LRonWXLVIJgtpeY3+xwWiIhiJ9ilXrKVGnfHe/c= -github.com/bndr/gotabulate v1.1.3-0.20170315142410-bc555436bfd5 h1:D48YSLPNJ8WpdwDqYF8bMMKUB2bgdWEiFx1MGwPIdbs= -github.com/bndr/gotabulate v1.1.3-0.20170315142410-bc555436bfd5/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= +github.com/bndr/gotabulate v1.1.3-0.20210209140214-21a495b00e22 h1:IsKzSX8XqgT8xSo4nxtTOH7014e1L+vPB1wh3IqkWr0= +github.com/bndr/gotabulate v1.1.3-0.20210209140214-21a495b00e22/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= diff --git a/vendor/github.com/bndr/gotabulate/tabulate.go b/vendor/github.com/bndr/gotabulate/tabulate.go index a2e43265..e6684d22 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 @@ -292,7 +296,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)) } @@ -385,7 +389,8 @@ func (t *Tabulate) SetEmptyString(empty string) { // Can be: // top - Top line of the table, // belowheader - Line below the header, -// bottom - Bottom line of the table +// bottomLine - Bottom line of the table +// betweenLine - Between line of the table func (t *Tabulate) SetHideLines(hide []string) { t.HideLines = hide } @@ -401,6 +406,12 @@ func (t *Tabulate) SetMaxCellSize(max int) { t.MaxSize = max } +// Sets dense mode +// Under dense mode, no space line between rows +func (t *Tabulate) SetDenseMode() { + t.DenseMode = true +} + func (t *Tabulate) splitElement(e string) (bool, string) { //check if we are not attempting to smartly wrap if t.WrapDelimiter == 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index bb224e3e..0017d4a3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -33,7 +33,7 @@ github.com/acarl005/stripansi github.com/beorn7/perks/quantile # github.com/blang/semver v4.0.0+incompatible github.com/blang/semver -# github.com/bndr/gotabulate v1.1.3-0.20170315142410-bc555436bfd5 +# github.com/bndr/gotabulate v1.1.3-0.20210209140214-21a495b00e22 github.com/bndr/gotabulate # github.com/cespare/xxhash/v2 v2.1.1 github.com/cespare/xxhash/v2 -- 2.27.0