printers

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 14 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVPrinter added in v0.12.0

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

func NewCSVPrinter added in v0.12.0

func NewCSVPrinter(config *CSVPrinterConfig) *CSVPrinter

func (*CSVPrinter) Print added in v0.12.0

func (cp *CSVPrinter) Print(data any) error

func (*CSVPrinter) WithOut added in v0.12.0

func (cp *CSVPrinter) WithOut(out io.Writer) *CSVPrinter

type CSVPrinterConfig added in v0.12.0

type CSVPrinterConfig struct {
	// ToHeaderAndRows is called during print to obtain the headers and rows for the given data.
	ToHeaderAndRows func(data any) ([]string, [][]string, error)
	// NoHeaders will omit headers during pring when set to true
	NoHeaders bool
	// Out defines the output writer for the printer, will default to os.stdout
	Out io.Writer
	// Delimiter the char to separate the columns, default is ";"
	Delimiter rune
}

type JSONPrinter

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

JSONPrinter prints data in JSON format

func NewJSONPrinter

func NewJSONPrinter() *JSONPrinter

func (*JSONPrinter) Print

func (p *JSONPrinter) Print(data any) error

func (*JSONPrinter) WithDisableDefaultErrorPrinter added in v0.12.0

func (p *JSONPrinter) WithDisableDefaultErrorPrinter() *JSONPrinter

func (*JSONPrinter) WithOut

func (p *JSONPrinter) WithOut(out io.Writer) *JSONPrinter

type Printer

type Printer interface {
	Print(data any) error
}

type ProtoJSONPrinter

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

ProtoJSONPrinter prints data of type proto.Message in JSON format

func NewProtoJSONPrinter

func NewProtoJSONPrinter() *ProtoJSONPrinter

func (*ProtoJSONPrinter) Print

func (p *ProtoJSONPrinter) Print(data any) error

func (*ProtoJSONPrinter) WithFallback

func (p *ProtoJSONPrinter) WithFallback(fallback bool) *ProtoJSONPrinter

func (*ProtoJSONPrinter) WithOut

func (p *ProtoJSONPrinter) WithOut(out io.Writer) *ProtoJSONPrinter

type ProtoYAMLPrinter

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

ProtoYAMLPrinter prints data of type proto.Message in YAML format

func NewProtoYAMLPrinter

func NewProtoYAMLPrinter() *ProtoYAMLPrinter

func (*ProtoYAMLPrinter) Print

func (p *ProtoYAMLPrinter) Print(data any) error

func (*ProtoYAMLPrinter) WithFallback

func (p *ProtoYAMLPrinter) WithFallback(fallback bool) *ProtoYAMLPrinter

func (*ProtoYAMLPrinter) WithOut

func (p *ProtoYAMLPrinter) WithOut(out io.Writer) *ProtoYAMLPrinter

type TablePrinter

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

TablePrinter prints data into a table

func NewTablePrinter

func NewTablePrinter(config *TablePrinterConfig) *TablePrinter

func (*TablePrinter) MutateTable

func (p *TablePrinter) MutateTable(mutateFn func(table *tablewriter.Table))

MutateTable can be used to alter the table element. Try not to do it all the time but rather propose an API change in this project.

func (*TablePrinter) Print

func (p *TablePrinter) Print(data any) error

func (*TablePrinter) WithOut

func (p *TablePrinter) WithOut(out io.Writer) *TablePrinter

type TablePrinterConfig

type TablePrinterConfig struct {
	// ToHeaderAndRows is called during print to obtain the headers and rows for the given data.
	ToHeaderAndRows func(data any, wide bool) ([]string, [][]string, error)
	// Wide is passed to the headers and rows function and allows to provide extendend columns.
	Wide bool
	// Markdown will print the table in Markdown format
	Markdown bool
	// NoHeaders will omit headers during pring when set to true
	NoHeaders bool
	// Out defines the output writer for the printer, will default to os.stdout
	Out io.Writer
	// CustomPadding defines the table padding, defaults to three whitespaces
	CustomPadding *string
	// DisableDefaultErrorPrinter disables the default error printer when the given print data is of type error.
	DisableDefaultErrorPrinter bool
}

TablePrinterConfig contains the configuration for the table printer

type TemplatePrinter

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

TemplatePrinter prints data with a given template

func NewTemplatePrinter

func NewTemplatePrinter(template string) *TemplatePrinter

func (*TemplatePrinter) Print

func (p *TemplatePrinter) Print(data any) error

func (*TemplatePrinter) WithOut

func (p *TemplatePrinter) WithOut(out io.Writer) *TemplatePrinter

func (*TemplatePrinter) WithTemplate

func (p *TemplatePrinter) WithTemplate(t *template.Template) *TemplatePrinter

type YAMLPrinter

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

YAMLPrinter prints data in YAML format

func NewYAMLPrinter

func NewYAMLPrinter() *YAMLPrinter

func (*YAMLPrinter) Print

func (p *YAMLPrinter) Print(data any) error

func (*YAMLPrinter) WithDisableDefaultErrorPrinter added in v0.12.0

func (p *YAMLPrinter) WithDisableDefaultErrorPrinter() *YAMLPrinter

func (*YAMLPrinter) WithOut

func (p *YAMLPrinter) WithOut(out io.Writer) *YAMLPrinter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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