2023-07-06 13:48:19 +02:00
|
|
|
package table
|
|
|
|
|
|
|
|
import (
|
2023-09-14 13:45:18 +02:00
|
|
|
"io"
|
2023-07-06 13:48:19 +02:00
|
|
|
|
2023-09-05 10:55:01 +02:00
|
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/output/color"
|
2023-07-06 13:48:19 +02:00
|
|
|
"github.com/lensesio/tableprinter"
|
|
|
|
)
|
|
|
|
|
2023-09-05 10:55:01 +02:00
|
|
|
func rowsLength(length int) bool {
|
|
|
|
return length > 10
|
|
|
|
}
|
|
|
|
|
2023-09-14 13:45:18 +02:00
|
|
|
func NewTablePrinter(out io.Writer) *tableprinter.Printer {
|
|
|
|
printer := tableprinter.New(out)
|
2023-07-06 13:48:19 +02:00
|
|
|
printer.BorderTop, printer.BorderBottom, printer.BorderLeft, printer.BorderRight = true, true, true, true
|
|
|
|
printer.CenterSeparator = "│"
|
|
|
|
printer.ColumnSeparator = "│"
|
|
|
|
printer.RowSeparator = "─"
|
|
|
|
printer.RowCharLimit = 300
|
|
|
|
printer.HeaderBgColor = color.HeaderBgColor
|
|
|
|
printer.HeaderFgColor = color.HeaderFgColor
|
2023-09-05 10:55:01 +02:00
|
|
|
printer.RowLengthTitle = rowsLength
|
2023-07-06 13:48:19 +02:00
|
|
|
return printer
|
|
|
|
}
|