printer

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJSON

func NewJSON(data []map[string]interface{}, options Options) *structPrinter

func NewSingle

func NewSingle(data []map[string]interface{}, field string) *singlePrinter

func NewTable

func NewTable(data []map[string]interface{}, header []string) *tablePrinter

func NewYAML

func NewYAML(data []map[string]interface{}, options Options) *structPrinter

Types

type DataFn

type DataFn func(fields []string) map[string]interface{}

DataFn defines the function signature needed to implement the Printable interface

type Format

type Format int
const (
	FormatJSON Format = iota
	FormatYAML
	FormatTable
	FormatSingle
	InvalidFormat
)

func ParseFormat

func ParseFormat(format string) (Format, error)

type Options

type Options struct {
	// Some printers can wrap the resulting elements
	// in a list. This option controls if the printer
	// should also wrap a single result element in a list.
	ListWrapSingleItem bool
}

type Printable

type Printable interface {
	PrinterData(fields []string) map[string]interface{}
}

func NewJob

func NewJob(fn DataFn) Printable

NewJob returns a struct that implements the Printable interface. It expects a function that generates the expected printer data given a list of fields to be printed

type Printer

type Printer interface {
	Print()
}

func New

func New(format Format, fields []string, queue Queue, options Options) (Printer, error)

type Queue

type Queue []Printable

Jump to

Keyboard shortcuts

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