printer

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT-0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALIGN_DEFAULT = iota
	ALIGN_CENTER
	ALIGN_RIGHT
	ALIGN_LEFT
)

Variables

This section is empty.

Functions

func EncodeJSON

func EncodeJSON(w io.Writer, obj interface{}) error

func EncodeYAML

func EncodeYAML(w io.Writer, obj interface{}) error

Types

type Output

type Output string
const (
	JSON  Output = "json"
	Table Output = "table"
	YAML  Output = "yaml"
)

func NewOutput

func NewOutput(outputType string) (Output, error)

func (Output) Print

func (o Output) Print(out io.Writer, printer ResourcePrinter) error

type ResourcePrinter

type ResourcePrinter interface {
	PrintJSON(io.Writer) error
	PrintTable(io.Writer) error
	PrintYAML(io.Writer) error
}

type TablePrinter

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

func NewTablePrinter

func NewTablePrinter() *TablePrinter

TODO: use make to set the size of the slice

func (*TablePrinter) AppendRow

func (p *TablePrinter) AppendRow(row []string)

func (*TablePrinter) NoTextWrap

func (p *TablePrinter) NoTextWrap()

func (*TablePrinter) Print

func (p *TablePrinter) Print(writer io.Writer)

func (*TablePrinter) SeparateRows

func (p *TablePrinter) SeparateRows()

func (*TablePrinter) SetColumnAlignment

func (p *TablePrinter) SetColumnAlignment(keys []int)

func (*TablePrinter) SetHeader

func (p *TablePrinter) SetHeader(header []string)

func (*TablePrinter) TruncateBeginning added in v0.15.0

func (p *TablePrinter) TruncateBeginning(text string, max int) string

func (*TablePrinter) TruncateMiddle added in v0.15.0

func (p *TablePrinter) TruncateMiddle(text string, max int) string

func (*TablePrinter) TruncateMiddleWithEllipsisLocation added in v0.15.0

func (p *TablePrinter) TruncateMiddleWithEllipsisLocation(text string, ellipisLocation, max int) string

Jump to

Keyboard shortcuts

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