From 230944d33e1af40c046c4147e33edcb6938c3a84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:34:43 +0000 Subject: [PATCH] Go: Bump github.com/jedib0t/go-pretty/v6 from 6.4.3 to 6.4.7 Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.4.3 to 6.4.7. - [Release notes](https://github.com/jedib0t/go-pretty/releases) - [Commits](https://github.com/jedib0t/go-pretty/compare/v6.4.3...v6.4.7) --- updated-dependencies: - dependency-name: github.com/jedib0t/go-pretty/v6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../jedib0t/go-pretty/v6/table/render.go | 15 ++-- .../jedib0t/go-pretty/v6/table/render_hint.go | 5 ++ .../jedib0t/go-pretty/v6/table/render_html.go | 4 +- .../jedib0t/go-pretty/v6/table/render_init.go | 8 +- .../go-pretty/v6/table/render_markdown.go | 9 +- .../jedib0t/go-pretty/v6/table/style.go | 62 ++++++------- .../jedib0t/go-pretty/v6/table/table.go | 47 ++++++++-- .../jedib0t/go-pretty/v6/table/util.go | 2 +- .../jedib0t/go-pretty/v6/table/writer.go | 2 +- .../jedib0t/go-pretty/v6/text/align.go | 2 +- .../jedib0t/go-pretty/v6/text/ansi_windows.go | 4 +- .../jedib0t/go-pretty/v6/text/color.go | 12 +-- .../jedib0t/go-pretty/v6/text/color_html.go | 90 +++++++++---------- .../jedib0t/go-pretty/v6/text/escape.go | 50 +++++++++++ .../jedib0t/go-pretty/v6/text/hyperlink.go | 14 +++ .../jedib0t/go-pretty/v6/text/string.go | 86 +++++++----------- .../jedib0t/go-pretty/v6/text/transformer.go | 8 +- vendor/modules.txt | 2 +- 20 files changed, 247 insertions(+), 181 deletions(-) create mode 100644 vendor/github.com/jedib0t/go-pretty/v6/text/escape.go create mode 100644 vendor/github.com/jedib0t/go-pretty/v6/text/hyperlink.go diff --git a/go.mod b/go.mod index 32e663d82ac..84912a860fe 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.5.9 github.com/gorilla/mux v1.8.0 - github.com/jedib0t/go-pretty/v6 v6.4.3 + github.com/jedib0t/go-pretty/v6 v6.4.7 github.com/kubernetes-sigs/service-catalog v0.3.1 github.com/mattn/go-colorable v0.1.13 github.com/olekukonko/tablewriter v0.0.5 diff --git a/go.sum b/go.sum index 8f9f61b4a71..f0d5198d8e8 100644 --- a/go.sum +++ b/go.sum @@ -765,8 +765,8 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jedib0t/go-pretty/v6 v6.4.3 h1:2n9BZ0YQiXGESUSR+6FLg0WWWE80u+mIz35f0uHWcIE= -github.com/jedib0t/go-pretty/v6 v6.4.3/go.mod h1:MgmISkTWDSFu0xOqiZ0mKNntMQ2mDgOcwOkwBEkMDJI= +github.com/jedib0t/go-pretty/v6 v6.4.7 h1:lwiTJr1DEkAgzljsUsORmWsVn5MQjt1BPJdPCtJ6KXE= +github.com/jedib0t/go-pretty/v6 v6.4.7/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/render.go b/vendor/github.com/jedib0t/go-pretty/v6/table/render.go index 8a13df54e73..ca4bc9908c5 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/render.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/render.go @@ -365,15 +365,16 @@ func (t *Table) renderRowsHeader(out *strings.Builder) { func (t *Table) renderTitle(out *strings.Builder) { if t.title != "" { colors := t.style.Title.Colors + colorsBorder := t.getBorderColors(renderHint{isTitleRow: true}) rowLength := t.maxRowLength if t.allowedRowLength != 0 && t.allowedRowLength < rowLength { rowLength = t.allowedRowLength } if t.style.Options.DrawBorder { lenBorder := rowLength - text.RuneWidthWithoutEscSequences(t.style.Box.TopLeft+t.style.Box.TopRight) - out.WriteString(colors.Sprint(t.style.Box.TopLeft)) - out.WriteString(colors.Sprint(text.RepeatAndTrim(t.style.Box.MiddleHorizontal, lenBorder))) - out.WriteString(colors.Sprint(t.style.Box.TopRight)) + out.WriteString(colorsBorder.Sprint(t.style.Box.TopLeft)) + out.WriteString(colorsBorder.Sprint(text.RepeatAndTrim(t.style.Box.MiddleHorizontal, lenBorder))) + out.WriteString(colorsBorder.Sprint(t.style.Box.TopRight)) } lenText := rowLength - text.RuneWidthWithoutEscSequences(t.style.Box.PaddingLeft+t.style.Box.PaddingRight) @@ -382,12 +383,12 @@ func (t *Table) renderTitle(out *strings.Builder) { } titleText := text.WrapText(t.title, lenText) for _, titleLine := range strings.Split(titleText, "\n") { - t.renderTitleLine(out, lenText, titleLine, colors) + t.renderTitleLine(out, lenText, titleLine, colors, colorsBorder) } } } -func (t *Table) renderTitleLine(out *strings.Builder, lenText int, titleLine string, colors text.Colors) { +func (t *Table) renderTitleLine(out *strings.Builder, lenText int, titleLine string, colors text.Colors, colorsBorder text.Colors) { titleLine = strings.TrimSpace(titleLine) titleLine = t.style.Title.Format.Apply(titleLine) titleLine = t.style.Title.Align.Apply(titleLine, lenText) @@ -397,10 +398,10 @@ func (t *Table) renderTitleLine(out *strings.Builder, lenText int, titleLine str out.WriteRune('\n') } if t.style.Options.DrawBorder { - out.WriteString(colors.Sprint(t.style.Box.Left)) + out.WriteString(colorsBorder.Sprint(t.style.Box.Left)) } out.WriteString(colors.Sprint(titleLine)) if t.style.Options.DrawBorder { - out.WriteString(colors.Sprint(t.style.Box.Right)) + out.WriteString(colorsBorder.Sprint(t.style.Box.Right)) } } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/render_hint.go b/vendor/github.com/jedib0t/go-pretty/v6/table/render_hint.go index e585389da64..e46cdc845b0 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/render_hint.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/render_hint.go @@ -12,10 +12,15 @@ type renderHint struct { isLastLineOfRow bool // last-line of the current row? isLastRow bool // last-row of header/footer/regular-rows? isSeparatorRow bool // separator row? + isTitleRow bool // title row? rowLineNumber int // the line number for a multi-line row rowNumber int // the row number/index } +func (h *renderHint) isBorderOrSeparator() bool { + return h.isBorderTop || h.isSeparatorRow || h.isBorderBottom +} + func (h *renderHint) isRegularRow() bool { return !h.isHeaderRow && !h.isFooterRow } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/render_html.go b/vendor/github.com/jedib0t/go-pretty/v6/table/render_html.go index 10a73252705..bf712ec54c3 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/render_html.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/render_html.go @@ -112,7 +112,7 @@ func (t *Table) htmlRenderColumn(out *strings.Builder, colStr string) { out.WriteString(colStr) } -func (t *Table) htmlRenderColumnAttributes(out *strings.Builder, row rowStr, colIdx int, hint renderHint) { +func (t *Table) htmlRenderColumnAttributes(out *strings.Builder, colIdx int, hint renderHint) { // determine the HTML "align"/"valign" property values align := t.getAlign(colIdx, hint).HTMLProperty() vAlign := t.getVAlign(colIdx, hint).HTMLProperty() @@ -161,7 +161,7 @@ func (t *Table) htmlRenderRow(out *strings.Builder, row rowStr, hint renderHint) // write the row out.WriteString(" <") out.WriteString(colTagName) - t.htmlRenderColumnAttributes(out, row, colIdx, hint) + t.htmlRenderColumnAttributes(out, colIdx, hint) out.WriteString(">") if len(colStr) == 0 { out.WriteString(t.style.HTML.EmptyColumn) diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/render_init.go b/vendor/github.com/jedib0t/go-pretty/v6/table/render_init.go index c6fd97c9a1d..917879b96d6 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/render_init.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/render_init.go @@ -43,12 +43,8 @@ func (t *Table) analyzeAndStringifyColumn(colIdx int, col interface{}, hint rend } else { colStr = fmt.Sprint(col) } - if strings.Contains(colStr, "\t") { - colStr = strings.Replace(colStr, "\t", " ", -1) - } - if strings.Contains(colStr, "\r") { - colStr = strings.Replace(colStr, "\r", "", -1) - } + colStr = strings.ReplaceAll(colStr, "\t", " ") + colStr = strings.ReplaceAll(colStr, "\r", "") return fmt.Sprintf("%s%s", t.style.Format.Direction.Modifier(), colStr) } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go b/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go index 127adcdec3f..1a8c488f481 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go @@ -54,12 +54,8 @@ func (t *Table) markdownRenderRow(out *strings.Builder, row rowStr, hint renderH colStr = row[colIdx] } out.WriteRune(' ') - if strings.Contains(colStr, "|") { - colStr = strings.Replace(colStr, "|", "\\|", -1) - } - if strings.Contains(colStr, "\n") { - colStr = strings.Replace(colStr, "\n", "
", -1) - } + colStr = strings.ReplaceAll(colStr, "|", "\\|") + colStr = strings.ReplaceAll(colStr, "\n", "
") out.WriteString(colStr) out.WriteRune(' ') } @@ -94,7 +90,6 @@ func (t *Table) markdownRenderRows(out *strings.Builder, rows []rowStr, hint ren func (t *Table) markdownRenderRowsFooter(out *strings.Builder) { t.markdownRenderRows(out, t.rowsFooter, renderHint{isFooterRow: true}) - } func (t *Table) markdownRenderRowsHeader(out *strings.Builder) { diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/style.go b/vendor/github.com/jedib0t/go-pretty/v6/table/style.go index 2c1795c4208..cb850e88b43 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/style.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/style.go @@ -533,11 +533,13 @@ var ( // ColorOptions defines the ANSI colors to use for parts of the Table. type ColorOptions struct { - IndexColumn text.Colors // index-column colors (row #, etc.) + Border text.Colors // borders (if nil, uses one of the below) Footer text.Colors // footer row(s) colors Header text.Colors // header row(s) colors + IndexColumn text.Colors // index-column colors (row #, etc.) Row text.Colors // regular row(s) colors RowAlternate text.Colors // regular row(s) colors for the even-numbered rows + Separator text.Colors // separators (if nil, uses one of the above) } var ( @@ -552,18 +554,18 @@ var ( // ColorOptionsBlackOnBlueWhite renders Black text on Blue/White background. ColorOptionsBlackOnBlueWhite = ColorOptions{ - IndexColumn: text.Colors{text.BgHiBlue, text.FgBlack}, Footer: text.Colors{text.BgBlue, text.FgBlack}, Header: text.Colors{text.BgHiBlue, text.FgBlack}, + IndexColumn: text.Colors{text.BgHiBlue, text.FgBlack}, Row: text.Colors{text.BgHiWhite, text.FgBlack}, RowAlternate: text.Colors{text.BgWhite, text.FgBlack}, } // ColorOptionsBlackOnCyanWhite renders Black text on Cyan/White background. ColorOptionsBlackOnCyanWhite = ColorOptions{ - IndexColumn: text.Colors{text.BgHiCyan, text.FgBlack}, Footer: text.Colors{text.BgCyan, text.FgBlack}, Header: text.Colors{text.BgHiCyan, text.FgBlack}, + IndexColumn: text.Colors{text.BgHiCyan, text.FgBlack}, Row: text.Colors{text.BgHiWhite, text.FgBlack}, RowAlternate: text.Colors{text.BgWhite, text.FgBlack}, } @@ -571,9 +573,9 @@ var ( // ColorOptionsBlackOnGreenWhite renders Black text on Green/White // background. ColorOptionsBlackOnGreenWhite = ColorOptions{ - IndexColumn: text.Colors{text.BgHiGreen, text.FgBlack}, Footer: text.Colors{text.BgGreen, text.FgBlack}, Header: text.Colors{text.BgHiGreen, text.FgBlack}, + IndexColumn: text.Colors{text.BgHiGreen, text.FgBlack}, Row: text.Colors{text.BgHiWhite, text.FgBlack}, RowAlternate: text.Colors{text.BgWhite, text.FgBlack}, } @@ -581,18 +583,18 @@ var ( // ColorOptionsBlackOnMagentaWhite renders Black text on Magenta/White // background. ColorOptionsBlackOnMagentaWhite = ColorOptions{ - IndexColumn: text.Colors{text.BgHiMagenta, text.FgBlack}, Footer: text.Colors{text.BgMagenta, text.FgBlack}, Header: text.Colors{text.BgHiMagenta, text.FgBlack}, + IndexColumn: text.Colors{text.BgHiMagenta, text.FgBlack}, Row: text.Colors{text.BgHiWhite, text.FgBlack}, RowAlternate: text.Colors{text.BgWhite, text.FgBlack}, } // ColorOptionsBlackOnRedWhite renders Black text on Red/White background. ColorOptionsBlackOnRedWhite = ColorOptions{ - IndexColumn: text.Colors{text.BgHiRed, text.FgBlack}, Footer: text.Colors{text.BgRed, text.FgBlack}, Header: text.Colors{text.BgHiRed, text.FgBlack}, + IndexColumn: text.Colors{text.BgHiRed, text.FgBlack}, Row: text.Colors{text.BgHiWhite, text.FgBlack}, RowAlternate: text.Colors{text.BgWhite, text.FgBlack}, } @@ -600,27 +602,27 @@ var ( // ColorOptionsBlackOnYellowWhite renders Black text on Yellow/White // background. ColorOptionsBlackOnYellowWhite = ColorOptions{ - IndexColumn: text.Colors{text.BgHiYellow, text.FgBlack}, Footer: text.Colors{text.BgYellow, text.FgBlack}, Header: text.Colors{text.BgHiYellow, text.FgBlack}, + IndexColumn: text.Colors{text.BgHiYellow, text.FgBlack}, Row: text.Colors{text.BgHiWhite, text.FgBlack}, RowAlternate: text.Colors{text.BgWhite, text.FgBlack}, } // ColorOptionsBlueWhiteOnBlack renders Blue/White text on Black background. ColorOptionsBlueWhiteOnBlack = ColorOptions{ - IndexColumn: text.Colors{text.FgHiBlue, text.BgHiBlack}, Footer: text.Colors{text.FgBlue, text.BgHiBlack}, Header: text.Colors{text.FgHiBlue, text.BgHiBlack}, + IndexColumn: text.Colors{text.FgHiBlue, text.BgHiBlack}, Row: text.Colors{text.FgHiWhite, text.BgBlack}, RowAlternate: text.Colors{text.FgWhite, text.BgBlack}, } // ColorOptionsCyanWhiteOnBlack renders Cyan/White text on Black background. ColorOptionsCyanWhiteOnBlack = ColorOptions{ - IndexColumn: text.Colors{text.FgHiCyan, text.BgHiBlack}, Footer: text.Colors{text.FgCyan, text.BgHiBlack}, Header: text.Colors{text.FgHiCyan, text.BgHiBlack}, + IndexColumn: text.Colors{text.FgHiCyan, text.BgHiBlack}, Row: text.Colors{text.FgHiWhite, text.BgBlack}, RowAlternate: text.Colors{text.FgWhite, text.BgBlack}, } @@ -628,9 +630,9 @@ var ( // ColorOptionsGreenWhiteOnBlack renders Green/White text on Black // background. ColorOptionsGreenWhiteOnBlack = ColorOptions{ - IndexColumn: text.Colors{text.FgHiGreen, text.BgHiBlack}, Footer: text.Colors{text.FgGreen, text.BgHiBlack}, Header: text.Colors{text.FgHiGreen, text.BgHiBlack}, + IndexColumn: text.Colors{text.FgHiGreen, text.BgHiBlack}, Row: text.Colors{text.FgHiWhite, text.BgBlack}, RowAlternate: text.Colors{text.FgWhite, text.BgBlack}, } @@ -638,18 +640,18 @@ var ( // ColorOptionsMagentaWhiteOnBlack renders Magenta/White text on Black // background. ColorOptionsMagentaWhiteOnBlack = ColorOptions{ - IndexColumn: text.Colors{text.FgHiMagenta, text.BgHiBlack}, Footer: text.Colors{text.FgMagenta, text.BgHiBlack}, Header: text.Colors{text.FgHiMagenta, text.BgHiBlack}, + IndexColumn: text.Colors{text.FgHiMagenta, text.BgHiBlack}, Row: text.Colors{text.FgHiWhite, text.BgBlack}, RowAlternate: text.Colors{text.FgWhite, text.BgBlack}, } // ColorOptionsRedWhiteOnBlack renders Red/White text on Black background. ColorOptionsRedWhiteOnBlack = ColorOptions{ - IndexColumn: text.Colors{text.FgHiRed, text.BgHiBlack}, Footer: text.Colors{text.FgRed, text.BgHiBlack}, Header: text.Colors{text.FgHiRed, text.BgHiBlack}, + IndexColumn: text.Colors{text.FgHiRed, text.BgHiBlack}, Row: text.Colors{text.FgHiWhite, text.BgBlack}, RowAlternate: text.Colors{text.FgWhite, text.BgBlack}, } @@ -657,9 +659,9 @@ var ( // ColorOptionsYellowWhiteOnBlack renders Yellow/White text on Black // background. ColorOptionsYellowWhiteOnBlack = ColorOptions{ - IndexColumn: text.Colors{text.FgHiYellow, text.BgHiBlack}, Footer: text.Colors{text.FgYellow, text.BgHiBlack}, Header: text.Colors{text.FgHiYellow, text.BgHiBlack}, + IndexColumn: text.Colors{text.FgHiYellow, text.BgHiBlack}, Row: text.Colors{text.FgHiWhite, text.BgBlack}, RowAlternate: text.Colors{text.FgWhite, text.BgBlack}, } @@ -673,14 +675,12 @@ type FormatOptions struct { Row text.Format // (data) row(s) text format } -var ( - // FormatOptionsDefault defines sensible formatting options. - FormatOptionsDefault = FormatOptions{ - Footer: text.FormatUpper, - Header: text.FormatUpper, - Row: text.FormatDefault, - } -) +// FormatOptionsDefault defines sensible formatting options. +var FormatOptionsDefault = FormatOptions{ + Footer: text.FormatUpper, + Header: text.FormatUpper, + Row: text.FormatDefault, +} // HTMLOptions defines the global options to control HTML rendering. type HTMLOptions struct { @@ -690,19 +690,21 @@ type HTMLOptions struct { Newline string // string to replace "\n" characters with } -var ( - // DefaultHTMLOptions defines sensible HTML rendering defaults. - DefaultHTMLOptions = HTMLOptions{ - CSSClass: DefaultHTMLCSSClass, - EmptyColumn: " ", - EscapeText: true, - Newline: "
", - } -) +// DefaultHTMLOptions defines sensible HTML rendering defaults. +var DefaultHTMLOptions = HTMLOptions{ + CSSClass: DefaultHTMLCSSClass, + EmptyColumn: " ", + EscapeText: true, + Newline: "
", +} // Options defines the global options that determine how the Table is // rendered. type Options struct { + // DoNotColorBordersAndSeparators disables coloring all the borders and row + // or column separators. + DoNotColorBordersAndSeparators bool + // DrawBorder enables or disables drawing the border around the Table. // Example of a table where it is disabled: // # │ FIRST NAME │ LAST NAME │ SALARY │ diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/table.go b/vendor/github.com/jedib0t/go-pretty/v6/table/table.go index 297de86bf48..1801c1c51a9 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/table.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/table.go @@ -32,13 +32,13 @@ func (row rowStr) areEqual(colIdx1 int, colIdx2 int) bool { return colIdx1 >= 0 && colIdx2 < len(row) && row[colIdx1] == row[colIdx2] } -// Table helps print a 2-dimensional array in a human readable pretty-table. +// Table helps print a 2-dimensional array in a human-readable pretty-table. type Table struct { // allowedRowLength is the max allowed length for a row (or line of output) allowedRowLength int // enable automatic indexing of the rows and columns like a spreadsheet? autoIndex bool - // autoIndexVIndexMaxLength denotes the length in chars for the last rownum + // autoIndexVIndexMaxLength denotes the length in chars for the last row autoIndexVIndexMaxLength int // caption stores the text to be rendered just below the table; and doesn't // get used when rendered as a CSV @@ -228,7 +228,7 @@ func (t *Table) SetColumnConfigs(configs []ColumnConfig) { t.columnConfigs = configs } -// SetHTMLCSSClass sets the the HTML CSS Class to use on the node +// SetHTMLCSSClass sets the HTML CSS Class to use on the
node // when rendering the Table in HTML format. // // Deprecated: in favor of Style().HTML.CSSClass @@ -326,7 +326,13 @@ func (t *Table) getAutoIndexColumnIDs() rowStr { } func (t *Table) getBorderColors(hint renderHint) text.Colors { - if hint.isHeaderRow { + if t.style.Options.DoNotColorBordersAndSeparators { + return nil + } else if t.style.Color.Border != nil { + return t.style.Color.Border + } else if hint.isTitleRow { + return t.style.Title.Colors + } else if hint.isHeaderRow { return t.style.Color.Header } else if hint.isFooterRow { return t.style.Color.Footer @@ -381,9 +387,13 @@ func (t *Table) getBorderRight(hint renderHint) string { } func (t *Table) getColumnColors(colIdx int, hint renderHint) text.Colors { + if hint.isBorderOrSeparator() { + if colors := t.getColumnColorsForBorderOrSeparator(hint); colors != nil { + return colors + } + } if t.rowPainter != nil && hint.isRegularNonSeparatorRow() && !t.isIndexColumn(colIdx, hint) { - colors := t.rowsColors[hint.rowNumber-1] - if colors != nil { + if colors := t.rowsColors[hint.rowNumber-1]; colors != nil { return colors } } @@ -400,6 +410,19 @@ func (t *Table) getColumnColors(colIdx int, hint renderHint) text.Colors { return nil } +func (t *Table) getColumnColorsForBorderOrSeparator(hint renderHint) text.Colors { + if t.style.Options.DoNotColorBordersAndSeparators { + return text.Colors{} // not nil to force caller to paint with no colors + } + if (hint.isBorderBottom || hint.isBorderTop) && t.style.Color.Border != nil { + return t.style.Color.Border + } + if hint.isSeparatorRow && t.style.Color.Separator != nil { + return t.style.Color.Separator + } + return nil +} + func (t *Table) getColumnSeparator(row rowStr, colIdx int, hint renderHint) string { separator := t.style.Box.MiddleVertical if hint.isSeparatorRow { @@ -578,7 +601,13 @@ func (t *Table) getRowConfig(hint renderHint) RowConfig { } func (t *Table) getSeparatorColors(hint renderHint) text.Colors { - if hint.isHeaderRow { + if t.style.Options.DoNotColorBordersAndSeparators { + return nil + } else if (hint.isBorderBottom || hint.isBorderTop) && t.style.Color.Border != nil { + return t.style.Color.Border + } else if t.style.Color.Separator != nil { + return t.style.Color.Separator + } else if hint.isHeaderRow { return t.style.Color.Header } else if hint.isFooterRow { return t.style.Color.Footer @@ -722,13 +751,13 @@ func (t *Table) shouldMergeCellsVertically(colIdx int, hint renderHint) bool { rowPrev := t.getRow(hint.rowNumber-1, hint) rowNext := t.getRow(hint.rowNumber, hint) if colIdx < len(rowPrev) && colIdx < len(rowNext) { - return rowPrev[colIdx] == rowNext[colIdx] || "" == rowNext[colIdx] + return rowPrev[colIdx] == rowNext[colIdx] || rowNext[colIdx] == "" } } else { rowPrev := t.getRow(hint.rowNumber-2, hint) rowCurr := t.getRow(hint.rowNumber-1, hint) if colIdx < len(rowPrev) && colIdx < len(rowCurr) { - return rowPrev[colIdx] == rowCurr[colIdx] || "" == rowCurr[colIdx] + return rowPrev[colIdx] == rowCurr[colIdx] || rowCurr[colIdx] == "" } } } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/util.go b/vendor/github.com/jedib0t/go-pretty/v6/table/util.go index e6d2ed7124f..aa710125eb0 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/util.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/util.go @@ -21,7 +21,7 @@ func AutoIndexColumnID(colIdx int) string { type WidthEnforcer func(col string, maxLen int) string // widthEnforcerNone returns the input string as is without any modifications. -func widthEnforcerNone(col string, maxLen int) string { +func widthEnforcerNone(col string, _ int) string { return col } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go b/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go index c70ba33637d..c5ecb3e686c 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go @@ -4,7 +4,7 @@ import ( "io" ) -// Writer declares the interfaces that can be used to setup and render a table. +// Writer declares the interfaces that can be used to set up and render a table. type Writer interface { AppendFooter(row Row, configs ...RowConfig) AppendHeader(row Row, configs ...RowConfig) diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/align.go b/vendor/github.com/jedib0t/go-pretty/v6/text/align.go index ade9dedc160..764a1f82cff 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/align.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/align.go @@ -39,7 +39,7 @@ func (a Align) Apply(text string, maxLength int) string { if sLenWoE < maxLength { // left pad with half the number of spaces needed before using %text return fmt.Sprintf("%"+strconv.Itoa(maxLength+numEscChars)+"s", - text+strings.Repeat(" ", int((maxLength-sLenWoE)/2))) + text+strings.Repeat(" ", (maxLength-sLenWoE)/2)) } case AlignJustify: return a.justifyText(text, sLenWoE, maxLength) diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/ansi_windows.go b/vendor/github.com/jedib0t/go-pretty/v6/text/ansi_windows.go index d2a32881744..4f8b42f0685 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/ansi_windows.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/ansi_windows.go @@ -10,9 +10,7 @@ import ( "golang.org/x/sys/windows" ) -var ( - enableVTPMutex = sync.Mutex{} -) +var enableVTPMutex = sync.Mutex{} func areANSICodesSupported() bool { enableVTPMutex.Lock() diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/color.go b/vendor/github.com/jedib0t/go-pretty/v6/text/color.go index f5b7bdd3976..f42dfb385dc 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/color.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/color.go @@ -8,9 +8,7 @@ import ( "sync" ) -var ( - colorsEnabled = areANSICodesSupported() -) +var colorsEnabled = areANSICodesSupported() // DisableColors (forcefully) disables color coding globally. func DisableColors() { @@ -23,7 +21,7 @@ func EnableColors() { } // The logic here is inspired from github.com/fatih/color; the following is -// the the bare minimum logic required to print Colored to the console. +// the bare minimum logic required to print Colored to the console. // The differences: // * This one caches the escape sequences for cases with multiple colors // * This one handles cases where the incoming already has colors in the @@ -123,10 +121,8 @@ func (c Color) Sprintf(format string, a ...interface{}) string { // Example: Colors{FgCyan, BgBlack} type Colors []Color -var ( - // colorsSeqMap caches the escape sequence for a set of colors - colorsSeqMap = sync.Map{} -) +// colorsSeqMap caches the escape sequence for a set of colors +var colorsSeqMap = sync.Map{} // EscapeSeq returns the ANSI escape sequence for the colors set. func (c Colors) EscapeSeq() string { diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/color_html.go b/vendor/github.com/jedib0t/go-pretty/v6/text/color_html.go index 3e5c55be6d6..14fa17432e7 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/color_html.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/color_html.go @@ -1,48 +1,46 @@ package text -var ( - // colorCSSClassMap contains the equivalent CSS-class for all colors - colorCSSClassMap = map[Color]string{ - Bold: "bold", - Faint: "faint", - Italic: "italic", - Underline: "underline", - BlinkSlow: "blink-slow", - BlinkRapid: "blink-rapid", - ReverseVideo: "reverse-video", - Concealed: "concealed", - CrossedOut: "crossed-out", - FgBlack: "fg-black", - FgRed: "fg-red", - FgGreen: "fg-green", - FgYellow: "fg-yellow", - FgBlue: "fg-blue", - FgMagenta: "fg-magenta", - FgCyan: "fg-cyan", - FgWhite: "fg-white", - FgHiBlack: "fg-hi-black", - FgHiRed: "fg-hi-red", - FgHiGreen: "fg-hi-green", - FgHiYellow: "fg-hi-yellow", - FgHiBlue: "fg-hi-blue", - FgHiMagenta: "fg-hi-magenta", - FgHiCyan: "fg-hi-cyan", - FgHiWhite: "fg-hi-white", - BgBlack: "bg-black", - BgRed: "bg-red", - BgGreen: "bg-green", - BgYellow: "bg-yellow", - BgBlue: "bg-blue", - BgMagenta: "bg-magenta", - BgCyan: "bg-cyan", - BgWhite: "bg-white", - BgHiBlack: "bg-hi-black", - BgHiRed: "bg-hi-red", - BgHiGreen: "bg-hi-green", - BgHiYellow: "bg-hi-yellow", - BgHiBlue: "bg-hi-blue", - BgHiMagenta: "bg-hi-magenta", - BgHiCyan: "bg-hi-cyan", - BgHiWhite: "bg-hi-white", - } -) +// colorCSSClassMap contains the equivalent CSS-class for all colors +var colorCSSClassMap = map[Color]string{ + Bold: "bold", + Faint: "faint", + Italic: "italic", + Underline: "underline", + BlinkSlow: "blink-slow", + BlinkRapid: "blink-rapid", + ReverseVideo: "reverse-video", + Concealed: "concealed", + CrossedOut: "crossed-out", + FgBlack: "fg-black", + FgRed: "fg-red", + FgGreen: "fg-green", + FgYellow: "fg-yellow", + FgBlue: "fg-blue", + FgMagenta: "fg-magenta", + FgCyan: "fg-cyan", + FgWhite: "fg-white", + FgHiBlack: "fg-hi-black", + FgHiRed: "fg-hi-red", + FgHiGreen: "fg-hi-green", + FgHiYellow: "fg-hi-yellow", + FgHiBlue: "fg-hi-blue", + FgHiMagenta: "fg-hi-magenta", + FgHiCyan: "fg-hi-cyan", + FgHiWhite: "fg-hi-white", + BgBlack: "bg-black", + BgRed: "bg-red", + BgGreen: "bg-green", + BgYellow: "bg-yellow", + BgBlue: "bg-blue", + BgMagenta: "bg-magenta", + BgCyan: "bg-cyan", + BgWhite: "bg-white", + BgHiBlack: "bg-hi-black", + BgHiRed: "bg-hi-red", + BgHiGreen: "bg-hi-green", + BgHiYellow: "bg-hi-yellow", + BgHiBlue: "bg-hi-blue", + BgHiMagenta: "bg-hi-magenta", + BgHiCyan: "bg-hi-cyan", + BgHiWhite: "bg-hi-white", +} diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/escape.go b/vendor/github.com/jedib0t/go-pretty/v6/text/escape.go new file mode 100644 index 00000000000..abccef75e35 --- /dev/null +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/escape.go @@ -0,0 +1,50 @@ +package text + +import "strings" + +// Constants +const ( + CSIStartRune = rune(91) // [ + CSIStopRune = 'm' + EscapeReset = EscapeStart + "0" + EscapeStop + EscapeStart = "\x1b[" + EscapeStartRune = rune(27) // \x1b + EscapeStop = "m" + EscapeStopRune = 'm' + OSIStartRune = rune(93) // ] + OSIStopRune = '\\' +) + +type escKind int + +const ( + escKindUnknown escKind = iota + escKindCSI + escKindOSI +) + +type escSeq struct { + isIn bool + content strings.Builder + kind escKind +} + +func (e *escSeq) InspectRune(r rune) { + if !e.isIn && r == EscapeStartRune { + e.isIn = true + e.kind = escKindUnknown + e.content.Reset() + e.content.WriteRune(r) + } else if e.isIn { + switch { + case e.kind == escKindUnknown && r == CSIStartRune: + e.kind = escKindCSI + case e.kind == escKindUnknown && r == OSIStartRune: + e.kind = escKindOSI + case e.kind == escKindCSI && r == CSIStopRune || e.kind == escKindOSI && r == OSIStopRune: + e.isIn = false + e.kind = escKindUnknown + } + e.content.WriteRune(r) + } +} diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/hyperlink.go b/vendor/github.com/jedib0t/go-pretty/v6/text/hyperlink.go new file mode 100644 index 00000000000..00a551ae273 --- /dev/null +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/hyperlink.go @@ -0,0 +1,14 @@ +package text + +import "fmt" + +func Hyperlink(url, text string) string { + if url == "" { + return text + } + if text == "" { + return url + } + // source https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda + return fmt.Sprintf("\x1b]8;;%s\x1b\\%s\x1b]8;;\x1b\\", url, text) +} diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/string.go b/vendor/github.com/jedib0t/go-pretty/v6/text/string.go index 9eb30e50d33..6a21ddaf133 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/string.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/string.go @@ -7,15 +7,6 @@ import ( "github.com/mattn/go-runewidth" ) -// Constants -const ( - EscapeReset = EscapeStart + "0" + EscapeStop - EscapeStart = "\x1b[" - EscapeStartRune = rune(27) // \x1b - EscapeStop = "m" - EscapeStopRune = 'm' -) - // RuneWidth stuff var ( rwCondition = runewidth.NewCondition() @@ -35,23 +26,21 @@ func InsertEveryN(str string, runeToInsert rune, n int) string { sLen := RuneWidthWithoutEscSequences(str) var out strings.Builder out.Grow(sLen + (sLen / n)) - outLen, isEscSeq := 0, false + outLen, eSeq := 0, escSeq{} for idx, c := range str { - if c == EscapeStartRune { - isEscSeq = true + if eSeq.isIn { + eSeq.InspectRune(c) + out.WriteRune(c) + continue } - - if !isEscSeq && outLen > 0 && (outLen%n) == 0 && idx != sLen { + eSeq.InspectRune(c) + if !eSeq.isIn && outLen > 0 && (outLen%n) == 0 && idx != sLen { out.WriteRune(runeToInsert) } out.WriteRune(c) - if !isEscSeq { + if !eSeq.isIn { outLen += RuneWidth(c) } - - if isEscSeq && c == EscapeStopRune { - isEscSeq = false - } } return out.String() } @@ -60,21 +49,19 @@ func InsertEveryN(str string, runeToInsert rune, n int) string { // argument string. For ex.: // LongestLineLen("Ghost!\nCome back here!\nRight now!") == 15 func LongestLineLen(str string) int { - maxLength, currLength, isEscSeq := 0, 0, false + maxLength, currLength, eSeq := 0, 0, escSeq{} for _, c := range str { - if c == EscapeStartRune { - isEscSeq = true - } else if isEscSeq && c == EscapeStopRune { - isEscSeq = false + if eSeq.isIn { + eSeq.InspectRune(c) continue } - + eSeq.InspectRune(c) if c == '\n' { if currLength > maxLength { maxLength = currLength } currLength = 0 - } else if !isEscSeq { + } else if !eSeq.isIn { currLength += RuneWidth(c) } } @@ -164,15 +151,14 @@ func RuneWidth(r rune) int { // RuneWidthWithoutEscSequences("\x1b[33mGhost\x1b[0m") == 5 // RuneWidthWithoutEscSequences("\x1b[33mGhost\x1b[0") == 5 func RuneWidthWithoutEscSequences(str string) int { - count, isEscSeq := 0, false + count, eSeq := 0, escSeq{} for _, c := range str { - if c == EscapeStartRune { - isEscSeq = true - } else if isEscSeq { - if c == EscapeStopRune { - isEscSeq = false - } - } else { + if eSeq.isIn { + eSeq.InspectRune(c) + continue + } + eSeq.InspectRune(c) + if !eSeq.isIn { count += RuneWidth(c) } } @@ -211,27 +197,23 @@ func Trim(str string, maxLen int) string { var out strings.Builder out.Grow(maxLen) - outLen, isEscSeq, lastEscSeq := 0, false, strings.Builder{} + outLen, eSeq := 0, escSeq{} for _, sChr := range str { - out.WriteRune(sChr) - if sChr == EscapeStartRune { - isEscSeq = true - lastEscSeq.Reset() - lastEscSeq.WriteRune(sChr) - } else if isEscSeq { - lastEscSeq.WriteRune(sChr) - if sChr == EscapeStopRune { - isEscSeq = false - } - } else { + if eSeq.isIn { + eSeq.InspectRune(sChr) + out.WriteRune(sChr) + continue + } + eSeq.InspectRune(sChr) + if eSeq.isIn { + out.WriteRune(sChr) + continue + } + if outLen < maxLen { outLen++ - if outLen == maxLen { - break - } + out.WriteRune(sChr) + continue } } - if lastEscSeq.Len() > 0 && lastEscSeq.String() != EscapeReset { - out.WriteString(EscapeReset) - } return out.String() } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/transformer.go b/vendor/github.com/jedib0t/go-pretty/v6/text/transformer.go index 872d663ccbf..4551436cef5 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/transformer.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/transformer.go @@ -79,7 +79,7 @@ func transformInt(format string, val interface{}) string { return transform(int64(number)) } if number, ok := val.(int64); ok { - return transform(int64(number)) + return transform(number) } return "" } @@ -105,7 +105,7 @@ func transformUint(format string, val interface{}) string { return transform(uint64(number)) } if number, ok := val.(uint64); ok { - return transform(uint64(number)) + return transform(number) } return "" } @@ -125,7 +125,7 @@ func transformFloat(format string, val interface{}) string { return transform(float64(number)) } if number, ok := val.(float64); ok { - return transform(float64(number)) + return transform(number) } return "" } @@ -137,7 +137,7 @@ func NewJSONTransformer(prefix string, indent string) Transformer { if valStr, ok := val.(string); ok { var b bytes.Buffer if err := json.Indent(&b, []byte(strings.TrimSpace(valStr)), prefix, indent); err == nil { - return string(b.Bytes()) + return b.String() } } else if b, err := json.MarshalIndent(val, prefix, indent); err == nil { return string(b) diff --git a/vendor/modules.txt b/vendor/modules.txt index 35989f09a67..dc8d6c691d6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -478,7 +478,7 @@ github.com/inconshreveable/mousetrap # github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 ## explicit github.com/jbenet/go-context/io -# github.com/jedib0t/go-pretty/v6 v6.4.3 +# github.com/jedib0t/go-pretty/v6 v6.4.7 ## explicit; go 1.16 github.com/jedib0t/go-pretty/v6/table github.com/jedib0t/go-pretty/v6/text