printer

package
v0.0.0-...-e6112dc Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TypeJSON defines a JSON formatter.
	TypeJSON = Type("json")
	// TypeText defines a human-readable formatted formatter.
	TypeText = Type("text")
)

Variables

This section is empty.

Functions

func ColsMessage

func ColsMessage(cols []string) string

func GetHeaders

func GetHeaders(allColumns []string, defaultColumns []string, customColumns []string) []string

GetHeaders takes all columns of a resource and the value of the columns flag, returns the headers of the table. (Some legacy code might refer to these headers as "Columns")

allColumns can be found by using structs.Names on a Print struct (i.e. structs.Names(DatacenterPrint{}))

func GetHeadersAllDefault

func GetHeadersAllDefault(allColumns []string, customColumns []string) []string

GetHeadersAllDefault is like GetHeaders, but defaultColumns is same as allColumns. Useful for resources with small print table

func GetHeadersListAll

func GetHeadersListAll(allColumns []string, defaultColumns []string, parentCol string, customColumns []string, argAll bool) []string

func GetId

func GetId(r *resources.Response) string

func GetRequestId

func GetRequestId(path string) (string, error)

func GetRequestPath

func GetRequestPath(r *resources.Response) string

func WriteJSON

func WriteJSON(item interface{}, writer io.Writer) error

Types

type DefaultMsgPrint

type DefaultMsgPrint struct {
	Message interface{} `json:"Message,omitempty"`
}

type JSONPrinter

type JSONPrinter struct {
	Stdout io.Writer
	Stderr io.Writer
}

func (*JSONPrinter) GetStderr

func (p *JSONPrinter) GetStderr() io.Writer

func (*JSONPrinter) GetStdout

func (p *JSONPrinter) GetStdout() io.Writer

func (*JSONPrinter) Print

func (p *JSONPrinter) Print(v interface{}) error

func (*JSONPrinter) SetStderr

func (p *JSONPrinter) SetStderr(writer io.Writer)

func (*JSONPrinter) SetStdout

func (p *JSONPrinter) SetStdout(writer io.Writer)

func (*JSONPrinter) Verbose

func (p *JSONPrinter) Verbose(format string, a ...interface{})

func (*JSONPrinter) Warn

func (p *JSONPrinter) Warn(v interface{}) error

type PrintService

type PrintService interface {
	Print(interface{}) error
	Warn(interface{}) error
	Verbose(format string, a ...interface{})

	GetStdout() io.Writer
	SetStdout(io.Writer)
	GetStderr() io.Writer
	SetStderr(io.Writer)
}

type Registry

type Registry map[string]PrintService

func NewPrinterRegistry

func NewPrinterRegistry(out, outErr io.Writer, noHeaders bool) (Registry, error)

type Result

type Result struct {
	Message        string
	Resource       string
	Verb           string
	WaitForRequest bool
	WaitForState   bool
	Columns        []string
	KeyValue       []map[string]interface{}
	OutputJSON     interface{}

	ApiResponse *resources.Response
}

func (*Result) PrintJSON

func (prt *Result) PrintJSON(out io.Writer) error

func (*Result) PrintText

func (prt *Result) PrintText(out io.Writer, noHeaders bool) error

TODO: identical name to printText. Hard to decipher behaviour

type ResultPrint

type ResultPrint struct {
	Message   interface{} `json:"Status,omitempty"`
	RequestId interface{} `json:"RequestId,omitempty"`
	Output    interface{} `json:"Resources,omitempty"`
}

type TextPrinter

type TextPrinter struct {
	Stdout    io.Writer
	Stderr    io.Writer
	NoHeaders bool
}

func (*TextPrinter) GetStderr

func (p *TextPrinter) GetStderr() io.Writer

func (*TextPrinter) GetStdout

func (p *TextPrinter) GetStdout() io.Writer

func (*TextPrinter) Print

func (p *TextPrinter) Print(v interface{}) error

func (*TextPrinter) SetStderr

func (p *TextPrinter) SetStderr(writer io.Writer)

func (*TextPrinter) SetStdout

func (p *TextPrinter) SetStdout(writer io.Writer)

func (*TextPrinter) Verbose

func (p *TextPrinter) Verbose(format string, a ...interface{})

func (*TextPrinter) Warn

func (p *TextPrinter) Warn(v interface{}) error

type ToPrint

type ToPrint struct {
	Message string
}

type Type

type Type string

Type defines an formatter format.

func (Type) String

func (p Type) String() string

Directories

Path Synopsis
Package mock_printer is a generated GoMock package.
Package mock_printer is a generated GoMock package.

Jump to

Keyboard shortcuts

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