printer

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyValueOrDefault

func EmptyValueOrDefault(value, defaultValue string) string

EmptyValueOrDefault returns the value or a default placeholder

func FormatAge

func FormatAge(t time.Time) string

FormatAge formats time.Duration as a kubectl-style age string (e.g., "5d", "3h", "45m")

func FormatStatus

func FormatStatus(installed bool) string

FormatStatus returns a status string with kubectl-style formatting

func FormatTimestamp

func FormatTimestamp(t time.Time) string

FormatTimestamp formats a timestamp in kubectl style

func FormatTimestampShort

func FormatTimestampShort(t time.Time) string

FormatTimestampShort formats a timestamp in short format

func PrintError

func PrintError(message string)

PrintError prints an error message

func PrintInfo

func PrintInfo(message string)

PrintInfo prints an info message

func PrintSuccess

func PrintSuccess(message string)

PrintSuccess prints a success message with kubectl-style formatting

func PrintTable

func PrintTable(headers []string, rows [][]string, opts ...Option) error

PrintTable is a convenience function for simple table printing

func PrintWarning

func PrintWarning(message string)

PrintWarning prints a warning message

func TruncateString

func TruncateString(s string, maxLen int) string

TruncateString truncates a string to maxLen with ellipsis

Types

type Option

type Option func(*TablePrinter)

Option configures the TablePrinter

func WithNoHeaders

func WithNoHeaders() Option

WithNoHeaders disables header output

func WithOutputType

func WithOutputType(t OutputType) Option

WithOutputType sets the output type

func WithWide

func WithWide() Option

WithWide enables wide output format

type OutputType

type OutputType string

OutputType defines the output format

const (
	// OutputTypeTable outputs in table format (default)
	OutputTypeTable OutputType = "table"
	// OutputTypeWide outputs in table format with additional columns
	OutputTypeWide OutputType = "wide"
	// OutputTypeJSON outputs in JSON format
	OutputTypeJSON OutputType = "json"
	// OutputTypeYAML outputs in YAML format
	OutputTypeYAML OutputType = "yaml"
)

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

Printer handles various output formats

func New

func New(outputType OutputType, wide bool) *Printer

New creates a new printer with the specified output type

func (*Printer) PrintJSON

func (p *Printer) PrintJSON(data any) error

PrintJSON prints data in JSON format

func (*Printer) SetOutput

func (p *Printer) SetOutput(out io.Writer)

SetOutput sets the output writer

type TablePrinter

type TablePrinter struct {
	// contains filtered or unexported fields
}

TablePrinter handles formatted table output similar to kubectl

func NewTablePrinter

func NewTablePrinter(out io.Writer, opts ...Option) *TablePrinter

NewTablePrinter creates a new table printer with kubectl-style formatting It uses tabwriter for clean column alignment with minimal styling

func (*TablePrinter) AddRow

func (p *TablePrinter) AddRow(values ...any)

AddRow adds a data row to the table

func (*TablePrinter) Render

func (p *TablePrinter) Render() error

Render outputs the formatted table

func (*TablePrinter) SetHeaders

func (p *TablePrinter) SetHeaders(headers ...string)

SetHeaders sets the table headers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL