diff --git a/go.mod b/go.mod index 158e47ae2..4def956a0 100644 --- a/go.mod +++ b/go.mod @@ -9,11 +9,11 @@ require ( github.com/fatih/color v1.10.0 // indirect github.com/golang/mock v1.4.4 github.com/google/go-cmp v0.5.4 - github.com/jsanda/tablewriter v0.0.2-0.20190614032957-c4e45dc9c708 github.com/logrusorgru/aurora v2.0.3+incompatible github.com/mattn/go-isatty v0.0.12 github.com/mattn/go-runewidth v0.0.10 // indirect github.com/mholt/archiver/v3 v3.5.0 + github.com/olekukonko/tablewriter v0.0.4 github.com/rivo/uniseg v0.2.0 // indirect github.com/spf13/cobra v1.0.0 github.com/spf13/pflag v1.0.5 @@ -23,7 +23,7 @@ require ( golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect gopkg.in/auth0.v5 v5.8.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect - gopkg.in/yaml.v2 v2.2.8 // indirect + gopkg.in/yaml.v2 v2.2.8 ) // replace gopkg.in/auth0.v5 => ../auth0 diff --git a/go.sum b/go.sum index 25fd240d9..ed86f1162 100644 --- a/go.sum +++ b/go.sum @@ -87,8 +87,6 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-auth0/auth0 v1.3.1-0.20210127212542-c607f115fee8 h1:JnBenXTSmQNQxXwPwBR/QOGwqqLVngyg1KR1Fz9OMNI= -github.com/go-auth0/auth0 v1.3.1-0.20210127212542-c607f115fee8/go.mod h1:QQ9fgGj2Wpza15+Ho3mM6amMeKfhzHo2cixcOqdkoKk= github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba h1:q5mOa+S8JFpV5JzwTX5FImMekMxOkIGjWiH2OmSo92M= github.com/go-auth0/auth0 v1.3.1-0.20210128024326-898cafab69ba/go.mod h1:QQ9fgGj2Wpza15+Ho3mM6amMeKfhzHo2cixcOqdkoKk= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -165,8 +163,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jsanda/tablewriter v0.0.2-0.20190614032957-c4e45dc9c708 h1:iHNpdSksqNoMQLzebZoWhbRNlQbgaKKB+x/VrP+UDH8= -github.com/jsanda/tablewriter v0.0.2-0.20190614032957-c4e45dc9c708/go.mod h1:9Nb9KesU8Gu6NiQmPbF7ZV+lVoUvvIoO3GASEhHBdb0= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -198,7 +194,7 @@ github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -214,7 +210,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= +github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pierrec/lz4/v4 v4.0.3 h1:vNQKSVZNYUEAvRY9FaUXAF1XPbSOHJtDTiP41kzDz2E= github.com/pierrec/lz4/v4 v4.0.3/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index dfc439607..cf5c8e8bb 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/jsanda/tablewriter" + "github.com/olekukonko/tablewriter" ) // TODO(cyx): think about whether we should extract this function in the diff --git a/internal/display/display.go b/internal/display/display.go index 454716320..5f9a662b5 100644 --- a/internal/display/display.go +++ b/internal/display/display.go @@ -9,8 +9,8 @@ import ( "time" "github.com/auth0/auth0-cli/internal/ansi" - "github.com/jsanda/tablewriter" "github.com/logrusorgru/aurora" + "github.com/olekukonko/tablewriter" ) type OutputFormat string diff --git a/vendor/github.com/jsanda/tablewriter/go.mod b/vendor/github.com/jsanda/tablewriter/go.mod deleted file mode 100644 index 66f128100..000000000 --- a/vendor/github.com/jsanda/tablewriter/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/jsanda/tablewriter - -go 1.12 - -require ( - github.com/mattn/go-runewidth v0.0.4 - github.com/olekukonko/tablewriter v0.0.1 -) diff --git a/vendor/github.com/jsanda/tablewriter/go.sum b/vendor/github.com/jsanda/tablewriter/go.sum deleted file mode 100644 index 9d5e33527..000000000 --- a/vendor/github.com/jsanda/tablewriter/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88= -github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= diff --git a/vendor/github.com/jsanda/tablewriter/.gitignore b/vendor/github.com/olekukonko/tablewriter/.gitignore similarity index 100% rename from vendor/github.com/jsanda/tablewriter/.gitignore rename to vendor/github.com/olekukonko/tablewriter/.gitignore diff --git a/vendor/github.com/jsanda/tablewriter/.travis.yml b/vendor/github.com/olekukonko/tablewriter/.travis.yml similarity index 100% rename from vendor/github.com/jsanda/tablewriter/.travis.yml rename to vendor/github.com/olekukonko/tablewriter/.travis.yml diff --git a/vendor/github.com/jsanda/tablewriter/LICENSE.md b/vendor/github.com/olekukonko/tablewriter/LICENSE.md similarity index 100% rename from vendor/github.com/jsanda/tablewriter/LICENSE.md rename to vendor/github.com/olekukonko/tablewriter/LICENSE.md diff --git a/vendor/github.com/jsanda/tablewriter/README.md b/vendor/github.com/olekukonko/tablewriter/README.md similarity index 71% rename from vendor/github.com/jsanda/tablewriter/README.md rename to vendor/github.com/olekukonko/tablewriter/README.md index 92d71ed48..cb9b2ef46 100644 --- a/vendor/github.com/jsanda/tablewriter/README.md +++ b/vendor/github.com/olekukonko/tablewriter/README.md @@ -233,7 +233,63 @@ table.Render() #### Table with color Output ![Table with Color](https://cloud.githubusercontent.com/assets/6460392/21101956/bbc7b356-c0a1-11e6-9f36-dba694746efc.png) -#### Example 6 - Set table caption +#### Example - 7 Table Cells with Color + +Individual Cell Colors from `func Rich` take precedence over Column Colors + +```go +data := [][]string{ + []string{"Test1Merge", "HelloCol2 - 1", "HelloCol3 - 1", "HelloCol4 - 1"}, + []string{"Test1Merge", "HelloCol2 - 2", "HelloCol3 - 2", "HelloCol4 - 2"}, + []string{"Test1Merge", "HelloCol2 - 3", "HelloCol3 - 3", "HelloCol4 - 3"}, + []string{"Test2Merge", "HelloCol2 - 4", "HelloCol3 - 4", "HelloCol4 - 4"}, + []string{"Test2Merge", "HelloCol2 - 5", "HelloCol3 - 5", "HelloCol4 - 5"}, + []string{"Test2Merge", "HelloCol2 - 6", "HelloCol3 - 6", "HelloCol4 - 6"}, + []string{"Test2Merge", "HelloCol2 - 7", "HelloCol3 - 7", "HelloCol4 - 7"}, + []string{"Test3Merge", "HelloCol2 - 8", "HelloCol3 - 8", "HelloCol4 - 8"}, + []string{"Test3Merge", "HelloCol2 - 9", "HelloCol3 - 9", "HelloCol4 - 9"}, + []string{"Test3Merge", "HelloCol2 - 10", "HelloCol3 -10", "HelloCol4 - 10"}, +} + +table := tablewriter.NewWriter(os.Stdout) +table.SetHeader([]string{"Col1", "Col2", "Col3", "Col4"}) +table.SetFooter([]string{"", "", "Footer3", "Footer4"}) +table.SetBorder(false) + +table.SetHeaderColor(tablewriter.Colors{tablewriter.Bold, tablewriter.BgGreenColor}, + tablewriter.Colors{tablewriter.FgHiRedColor, tablewriter.Bold, tablewriter.BgBlackColor}, + tablewriter.Colors{tablewriter.BgRedColor, tablewriter.FgWhiteColor}, + tablewriter.Colors{tablewriter.BgCyanColor, tablewriter.FgWhiteColor}) + +table.SetColumnColor(tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiBlackColor}, + tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiRedColor}, + tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiBlackColor}, + tablewriter.Colors{tablewriter.Bold, tablewriter.FgBlackColor}) + +table.SetFooterColor(tablewriter.Colors{}, tablewriter.Colors{}, + tablewriter.Colors{tablewriter.Bold}, + tablewriter.Colors{tablewriter.FgHiRedColor}) + +colorData1 := []string{"TestCOLOR1Merge", "HelloCol2 - COLOR1", "HelloCol3 - COLOR1", "HelloCol4 - COLOR1"} +colorData2 := []string{"TestCOLOR2Merge", "HelloCol2 - COLOR2", "HelloCol3 - COLOR2", "HelloCol4 - COLOR2"} + +for i, row := range data { + if i == 4 { + table.Rich(colorData1, []tablewriter.Colors{tablewriter.Colors{}, tablewriter.Colors{tablewriter.Normal, tablewriter.FgCyanColor}, tablewriter.Colors{tablewriter.Bold, tablewriter.FgWhiteColor}, tablewriter.Colors{}}) + table.Rich(colorData2, []tablewriter.Colors{tablewriter.Colors{tablewriter.Normal, tablewriter.FgMagentaColor}, tablewriter.Colors{}, tablewriter.Colors{tablewriter.Bold, tablewriter.BgRedColor}, tablewriter.Colors{tablewriter.FgHiGreenColor, tablewriter.Italic, tablewriter.BgHiCyanColor}}) + } + table.Append(row) +} + +table.SetAutoMergeCells(true) +table.Render() + +``` + +##### Table cells with color Output +![Table cells with Color](https://user-images.githubusercontent.com/9064687/63969376-bcd88d80-ca6f-11e9-9466-c3d954700b25.png) + +#### Example 8 - Set table caption ```go data := [][]string{ []string{"A", "The Good", "500"}, @@ -254,7 +310,7 @@ table.Render() // Send output Note: Caption text will wrap with total width of rendered table. -##### Output 6 +##### Output 7 ``` +------+-----------------------+--------+ | NAME | SIGN | RATING | @@ -267,6 +323,41 @@ Note: Caption text will wrap with total width of rendered table. Movie ratings. ``` +#### Example 8 - Set NoWhiteSpace and TablePadding option +```go +data := [][]string{ + {"node1.example.com", "Ready", "compute", "1.11"}, + {"node2.example.com", "Ready", "compute", "1.11"}, + {"node3.example.com", "Ready", "compute", "1.11"}, + {"node4.example.com", "NotReady", "compute", "1.11"}, +} + +table := tablewriter.NewWriter(os.Stdout) +table.SetHeader([]string{"Name", "Status", "Role", "Version"}) +table.SetAutoWrapText(false) +table.SetAutoFormatHeaders(true) +table.SetHeaderAlignment(ALIGN_LEFT) +table.SetAlignment(ALIGN_LEFT) +table.SetCenterSeparator("") +table.SetColumnSeparator("") +table.SetRowSeparator("") +table.SetHeaderLine(false) +table.SetBorder(false) +table.SetTablePadding("\t") // pad with tabs +table.SetNoWhiteSpace(true) +table.AppendBulk(data) // Add Bulk Data +table.Render() +``` + +##### Output 8 +``` +NAME STATUS ROLE VERSION +node1.example.com Ready compute 1.11 +node2.example.com Ready compute 1.11 +node3.example.com Ready compute 1.11 +node4.example.com NotReady compute 1.11 +``` + #### Render table into a string Instead of rendering the table to `io.Stdout` you can also render it into a string. Go 1.10 introduced the `strings.Builder` type which implements the `io.Writer` interface and can therefore be used for this task. Example: @@ -283,7 +374,7 @@ import ( func main() { tableString := &strings.Builder{} - table := tablewriter.NewWriter(tableString) + table := tablewriter.NewWriter(tableString) /* * Code to fill the table diff --git a/vendor/github.com/jsanda/tablewriter/csv.go b/vendor/github.com/olekukonko/tablewriter/csv.go similarity index 100% rename from vendor/github.com/jsanda/tablewriter/csv.go rename to vendor/github.com/olekukonko/tablewriter/csv.go diff --git a/vendor/github.com/olekukonko/tablewriter/go.mod b/vendor/github.com/olekukonko/tablewriter/go.mod new file mode 100644 index 000000000..0430d99b0 --- /dev/null +++ b/vendor/github.com/olekukonko/tablewriter/go.mod @@ -0,0 +1,5 @@ +module github.com/olekukonko/tablewriter + +go 1.12 + +require github.com/mattn/go-runewidth v0.0.7 diff --git a/vendor/github.com/olekukonko/tablewriter/go.sum b/vendor/github.com/olekukonko/tablewriter/go.sum new file mode 100644 index 000000000..1e7b9aabd --- /dev/null +++ b/vendor/github.com/olekukonko/tablewriter/go.sum @@ -0,0 +1,2 @@ +github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= +github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= diff --git a/vendor/github.com/jsanda/tablewriter/table.go b/vendor/github.com/olekukonko/tablewriter/table.go similarity index 91% rename from vendor/github.com/jsanda/tablewriter/table.go rename to vendor/github.com/olekukonko/tablewriter/table.go index d4f2563fb..cf63eadfc 100644 --- a/vendor/github.com/jsanda/tablewriter/table.go +++ b/vendor/github.com/olekukonko/tablewriter/table.go @@ -72,6 +72,8 @@ type Table struct { newLine string rowLine bool autoMergeCells bool + noWhiteSpace bool + tablePadding string hdrLine bool borders Border colSize int @@ -139,48 +141,6 @@ func (t *Table) Render() { } } -func (t *Table) renderNoHeaders() { - if t.borders.Top { - t.printLine(true) - } - if t.autoMergeCells { - t.printRowsMergeCells() - } else { - t.printRows() - } - if !t.rowLine && t.borders.Bottom { - t.printLine(true) - } -} - -func (t *Table) ContinuousRender(rows <-chan []string) { - printHeaders := true - - for row := range rows { - colWidths := make(map[int]int) - for k, v := range t.cs { - colWidths[k] = v - } - - t.Append(row) - - for k, v := range t.cs { - if v != colWidths[k] { - printHeaders = true - break - } - } - - if printHeaders { - t.Render() - printHeaders = false - } else { - t.renderNoHeaders() - } - t.lines = [][][]string{} - } -} - const ( headerRowIdx = -1 footerRowIdx = -2 @@ -267,6 +227,16 @@ func (t *Table) SetAlignment(align int) { t.align = align } +// Set No White Space +func (t *Table) SetNoWhiteSpace(allow bool) { + t.noWhiteSpace = allow +} + +// Set Table Padding +func (t *Table) SetTablePadding(padding string) { + t.tablePadding = padding +} + func (t *Table) SetColumnAlignment(keys []int) { for _, v := range keys { switch v { @@ -338,6 +308,33 @@ func (t *Table) Append(row []string) { t.lines = append(t.lines, line) } +// Append row to table with color attributes +func (t *Table) Rich(row []string, colors []Colors) { + rowSize := len(t.headers) + if rowSize > t.colSize { + t.colSize = rowSize + } + + n := len(t.lines) + line := [][]string{} + for i, v := range row { + + // Detect string width + // Detect String height + // Break strings into words + out := t.parseDimension(v, i, n) + + if len(colors) > i { + color := colors[i] + out[0] = format(out[0], color) + } + + // Append broken words + line = append(line, out) + } + t.lines = append(t.lines, line) +} + // Allow Support for Bulk Append // Eliminates repeated for loops func (t *Table) AppendBulk(rows [][]string) { @@ -453,11 +450,14 @@ func (t *Table) printHeading() { for x := 0; x < max; x++ { // Check if border is set // Replace with space if not set - fmt.Fprint(t.out, ConditionString(t.borders.Left, t.pColumn, SPACE)) + if !t.noWhiteSpace { + fmt.Fprint(t.out, ConditionString(t.borders.Left, t.pColumn, SPACE)) + } for y := 0; y <= end; y++ { v := t.cs[y] h := "" + if y < len(t.headers) && x < len(t.headers[y]) { h = t.headers[y][x] } @@ -465,15 +465,30 @@ func (t *Table) printHeading() { h = Title(h) } pad := ConditionString((y == end && !t.borders.Left), SPACE, t.pColumn) - + if t.noWhiteSpace { + pad = ConditionString((y == end && !t.borders.Left), SPACE, t.tablePadding) + } if is_esc_seq { - fmt.Fprintf(t.out, " %s %s", - format(padFunc(h, SPACE, v), - t.headerParams[y]), pad) + if !t.noWhiteSpace { + fmt.Fprintf(t.out, " %s %s", + format(padFunc(h, SPACE, v), + t.headerParams[y]), pad) + } else { + fmt.Fprintf(t.out, "%s %s", + format(padFunc(h, SPACE, v), + t.headerParams[y]), pad) + } } else { - fmt.Fprintf(t.out, " %s %s", - padFunc(h, SPACE, v), - pad) + if !t.noWhiteSpace { + fmt.Fprintf(t.out, " %s %s", + padFunc(h, SPACE, v), + pad) + } else { + // the spaces between breaks the kube formatting + fmt.Fprintf(t.out, "%s%s", + padFunc(h, SPACE, v), + pad) + } } } // Next line @@ -696,9 +711,11 @@ func (t *Table) printRow(columns [][]string, rowIdx int) { for y := 0; y < total; y++ { // Check if border is set - fmt.Fprint(t.out, ConditionString((!t.borders.Left && y == 0), SPACE, t.pColumn)) + if !t.noWhiteSpace { + fmt.Fprint(t.out, ConditionString((!t.borders.Left && y == 0), SPACE, t.pColumn)) + fmt.Fprintf(t.out, SPACE) + } - fmt.Fprintf(t.out, SPACE) str := columns[y][x] // Embedding escape sequence with column value @@ -730,11 +747,17 @@ func (t *Table) printRow(columns [][]string, rowIdx int) { } } - fmt.Fprintf(t.out, SPACE) + if !t.noWhiteSpace { + fmt.Fprintf(t.out, SPACE) + } else { + fmt.Fprintf(t.out, t.tablePadding) + } } // Check if border is set // Replace with space if not set - fmt.Fprint(t.out, ConditionString(t.borders.Left, t.pColumn, SPACE)) + if !t.noWhiteSpace { + fmt.Fprint(t.out, ConditionString(t.borders.Left, t.pColumn, SPACE)) + } fmt.Fprint(t.out, t.newLine) } @@ -846,7 +869,7 @@ func (t *Table) printRowMergeCells(writer io.Writer, columns [][]string, rowIdx //The new previous line is the current one previousLine = make([]string, total) for y := 0; y < total; y++ { - previousLine[y] = strings.TrimRight(strings.Join(columns[y], " ")," ") //Store the full line for multi-lines cells + previousLine[y] = strings.TrimRight(strings.Join(columns[y], " "), " ") //Store the full line for multi-lines cells } //Returns the newly added line and wether or not a border should be displayed above. return previousLine, displayCellBorder diff --git a/vendor/github.com/jsanda/tablewriter/table_with_color.go b/vendor/github.com/olekukonko/tablewriter/table_with_color.go similarity index 98% rename from vendor/github.com/jsanda/tablewriter/table_with_color.go rename to vendor/github.com/olekukonko/tablewriter/table_with_color.go index 5a4a53ec2..ae7a364ae 100644 --- a/vendor/github.com/jsanda/tablewriter/table_with_color.go +++ b/vendor/github.com/olekukonko/tablewriter/table_with_color.go @@ -89,6 +89,8 @@ func format(s string, codes interface{}) string { seq = v case []int: seq = makeSequence(v) + case Colors: + seq = makeSequence(v) default: return s } diff --git a/vendor/github.com/jsanda/tablewriter/util.go b/vendor/github.com/olekukonko/tablewriter/util.go similarity index 100% rename from vendor/github.com/jsanda/tablewriter/util.go rename to vendor/github.com/olekukonko/tablewriter/util.go diff --git a/vendor/github.com/jsanda/tablewriter/wrap.go b/vendor/github.com/olekukonko/tablewriter/wrap.go similarity index 100% rename from vendor/github.com/jsanda/tablewriter/wrap.go rename to vendor/github.com/olekukonko/tablewriter/wrap.go diff --git a/vendor/modules.txt b/vendor/modules.txt index df81f9df9..50a06ee52 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -42,9 +42,6 @@ github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value # github.com/inconshreveable/mousetrap v1.0.0 github.com/inconshreveable/mousetrap -# github.com/jsanda/tablewriter v0.0.2-0.20190614032957-c4e45dc9c708 -## explicit -github.com/jsanda/tablewriter # github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kballard/go-shellquote # github.com/klauspost/compress v1.10.10 @@ -77,6 +74,9 @@ github.com/mholt/archiver/v3 github.com/mitchellh/mapstructure # github.com/nwaples/rardecode v1.1.0 github.com/nwaples/rardecode +# github.com/olekukonko/tablewriter v0.0.4 +## explicit +github.com/olekukonko/tablewriter # github.com/pierrec/lz4/v4 v4.0.3 github.com/pierrec/lz4/v4 github.com/pierrec/lz4/v4/internal/lz4block