printers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JSON = Register("json", NewJSONPrinter())
)
View Source
var Registry = map[string]Printer{}
View Source
var (
	Table = Register("table", NewTablePrinter())
)

Functions

func ListFormats

func ListFormats() []string

Types

type JSONPrinter

type JSONPrinter struct{}

func NewJSONPrinter

func NewJSONPrinter() *JSONPrinter

func (*JSONPrinter) Print

func (*JSONPrinter) Print(w io.Writer, p Printable) error

func (*JSONPrinter) SetColumns added in v0.1.0

func (p *JSONPrinter) SetColumns(cols []string)

type Printable

type Printable interface {
	TableRows() []map[string]interface{}
}

type Printer

type Printer interface {
	Print(w io.Writer, p Printable) error
	SetColumns(cols []string)
}

func Get

func Get(format string) (Printer, error)

func Register

func Register(format string, p Printer) Printer

type TablePrinter

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

func NewTablePrinter

func NewTablePrinter() *TablePrinter

func (*TablePrinter) Print

func (printer *TablePrinter) Print(w io.Writer, p Printable) error

TODO: refactor

func (*TablePrinter) SetColumns added in v0.1.0

func (printer *TablePrinter) SetColumns(cols []string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳