Header row seperator for console Table (#10651)

master
P R 4 years ago committed by GitHub
parent 8ceb2a93fd
commit abb14aeec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      pkg/console/console.go

@ -353,13 +353,16 @@ type Table struct {
// Left margin width for table
TableIndentWidth int
// Flag to print separator under heading. Row 0 is considered heading
HeaderRowSeparator bool
}
// NewTable - create a new Table instance. Takes per-row colors and
// per-column right-align flags and table indentation width (i.e. left
// margin width)
func NewTable(rowColors []*color.Color, alignRight []bool, indentWidth int) *Table {
return &Table{rowColors, alignRight, indentWidth}
return &Table{rowColors, alignRight, indentWidth, false}
}
// DisplayTable - prints the table
@ -410,6 +413,11 @@ func (t *Table) DisplayTable(rows [][]string) error {
// Print the table with colors
for r, row := range paddedText {
if t.HeaderRowSeparator && r == 1 {
// Draw table header-row border
border = fmt.Sprintf("%s├%s┤", indentText, strings.Join(segments, "┼"))
fmt.Println(border)
}
fmt.Print(indentText + "│ ")
for c, text := range row {
t.RowColors[r].Print(text)

Loading…
Cancel
Save