Documentation
¶
Index ¶
- Constants
- func FormatFn[T any](formatFn func(PrintOptions, T) string) func(PrintOptions, interface{}) string
- func SprintfWithColor(color Color, format string, a ...interface{}) string
- type Cell
- type Color
- type Column
- type KubectlPrinter
- type OutStreams
- type PeriodicPrinter
- type PrintOptions
- type StatusPrinter
- type TreePrinter
Constants ¶
const ( // RESET is the escape sequence for unsetting any previous commands. RESET = 0 // ESC is the escape sequence used to send ANSI commands in the terminal. ESC = 27 )
Variables ¶
This section is empty.
Functions ¶
func FormatFn ¶
func FormatFn[T any](formatFn func(PrintOptions, T) string) func(PrintOptions, interface{}) string
FormatFn is a wrapper of a function of specific type to a function of interface{}. It acts as an adapter to allow using the function with the Column.FormatFn.
func SprintfWithColor ¶
SprintfWithColor formats according to the provided pattern and returns the result as a string with the necessary ansii escape codes for color
Types ¶
type Column ¶
type Column struct { Header string Width int MaxLineWrap int // Maximum number of lines to wrap the content to. WrapPrefix string FormatFn func(o PrintOptions, obj interface{}) string }
Column defines a column in a table.
func (Column) Format ¶
func (c Column) Format(o PrintOptions, obj interface{}) Cell
Format turns the object into a string for the Cell using the FormatFn.
type KubectlPrinter ¶ added in v0.3.0
type KubectlPrinter struct {
Printer printers.ResourcePrinter
}
func (KubectlPrinter) PrintStatuses ¶ added in v0.3.0
func (p KubectlPrinter) PrintStatuses(statuses []status.ObjectStatus, w io.Writer)
type PeriodicPrinter ¶
type PeriodicPrinter struct {
// contains filtered or unexported fields
}
PeriodicPrinter prints status updates to the terminal, as they arrive to the update channel. It tracks the number of lines printed and clears the screen before printing the next update.
func NewPeriodicPrinter ¶
func NewPeriodicPrinter(printer StatusPrinter, out OutStreams, updateChan <-chan eval.StatusUpdate, callback func([]status.ObjectStatus)) *PeriodicPrinter
func (*PeriodicPrinter) Start ¶
func (p *PeriodicPrinter) Start()
type PrintOptions ¶
type StatusPrinter ¶
type StatusPrinter interface {
PrintStatuses(statuses []status.ObjectStatus, w io.Writer)
}
StatusPrinter is an interface for printing status updates.
type TreePrinter ¶ added in v0.3.0
type TreePrinter struct {
PrintOpts PrintOptions
}
TreePrinter implements StatusPrinter interface for printing the status of resources in a tabular format.
func NewTreePrinter ¶ added in v0.3.0
func NewTreePrinter(opts PrintOptions) *TreePrinter
func (*TreePrinter) PrintStatuses ¶ added in v0.3.0
func (t *TreePrinter) PrintStatuses(objects []status.ObjectStatus, w io.Writer)