format

package
v1.0.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//OutputTypePretty is used for pretty printing
	OutputTypePretty = "pretty"
	//OutputTypeRaw is used for raw output (nice for unix piping)
	OutputTypeRaw = "raw"
	//OutputTypeJSON is used for JSON output
	OutputTypeJSON = "json"
)

Variables

This section is empty.

Functions

func NotImplDecorator

func NotImplDecorator(ot OutputType) *notImplDecorator

NotImplDecorator can be used when a decorator is not implemented

Types

type DecMap

type DecMap map[OutputType]Decorator

DecMap maps an OutputType to a Decorator

type Decorator

type Decorator interface {
	Decorate(out io.Writer) error
}

Decorator decorates a value and writes to out

type JSONDecorator

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

JSONDecorator decorates by parsing JSON

func NewJSONDecorator

func NewJSONDecorator(v interface{}) *JSONDecorator

NewJSONDecorator is a decorator that outputs JSON

func (*JSONDecorator) Decorate

func (d *JSONDecorator) Decorate(out io.Writer) error

Decorate writes JSON to out

type OutputType

type OutputType string

OutputType is one of prett, raw, or json

type Outputter

type Outputter struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

Outputter is responsible for all output

func NewOutputter

func NewOutputter(outw, errw io.Writer, logger *log.Logger) *Outputter

NewOutputter creates a new Outputter that writes to Stdout and Stderr

func (*Outputter) Close

func (o *Outputter) Close() error

Close closes the log file

func (*Outputter) ErrW

func (o *Outputter) ErrW() io.Writer

ErrW returns the err writer

func (*Outputter) Output

func (o *Outputter) Output(d DecMap)

Output outputs using the right decorator

func (*Outputter) SetDebug

func (o *Outputter) SetDebug(debug bool)

SetDebug sets debug outputting

func (*Outputter) SetLogToDisk

func (o *Outputter) SetLogToDisk(location string) error

SetLogToDisk sets a logfile to write to

func (*Outputter) SetOutputType

func (o *Outputter) SetOutputType(ot OutputType)

SetOutputType sets the output type

func (*Outputter) WriteError

func (o *Outputter) WriteError(err error)

WriteError writes an error to errw

type TableDecorator

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

TableDecorator will attempt to structure a table

func NewTableDecorator

func NewTableDecorator(v interface{}, header, tmpl string) *TableDecorator

NewTableDecorator is a decorator that writes a table using golang's templating

func (*TableDecorator) Decorate

func (d *TableDecorator) Decorate(out io.Writer) error

Decorate writes the table to out

type TmplDecorator

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

TmplDecorator decorates by simply executing a template

func NewTmplDecorator

func NewTmplDecorator(v interface{}, tmpl string) *TmplDecorator

NewTmplDecorator is a decorator that uses golang's templating

func (*TmplDecorator) Decorate

func (d *TmplDecorator) Decorate(out io.Writer) error

Decorate writes templated output to out

Jump to

Keyboard shortcuts

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