printers

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 13 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) 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
}

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) 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