output

package
Version: v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSV

func CSV(rows []*OrderedFields) error

CSV outputs provided rows as CSV to stdout

func CommandOutput added in v1.1.13

func CommandOutput(cmd *cobra.Command, out OutputHandlerDataProvider) error

func CommandOutputPaginated added in v1.1.13

func CommandOutputPaginated(cmd *cobra.Command, out OutputHandlerDataProvider, paginated connection.Paginated) error

func Error

func Error(str string)

Error writes specified string to stderr

func Errorf

func Errorf(format string, a ...interface{})

Errorf writes specified string with formatting to stderr

func ExitWithErrorLevel added in v1.1.13

func ExitWithErrorLevel()

func Fatal

func Fatal(str string)

Fatal writes specified string to stderr and calls outputExit to exit with 1

func Fatalf

func Fatalf(format string, a ...interface{})

Fatalf writes specified string with formatting to stderr and calls outputExit to exit with 1

func JSON

func JSON(v interface{}) error

JSON marshals and outputs value v to stdout

func JSONPath added in v1.1.13

func JSONPath(query string, v interface{}) error

JSONPath marshals and outputs value v to stdout

func List added in v1.1.0

func List(rows []*OrderedFields) error

List will format specified rows using given includeProperties by extracting fields, and output them to stdout

func OutputWithCustomErrorLevel added in v1.1.13

func OutputWithCustomErrorLevel(level int, str string)

OutputWithCustomErrorLevel is a wrapper for OutputError, which sets global var errorLevel with provided level

func OutputWithCustomErrorLevelf added in v1.1.13

func OutputWithCustomErrorLevelf(level int, format string, a ...interface{})

OutputWithCustomErrorLevelf is a wrapper for OutputWithCustomErrorLevel, which sets global var errorLevel with provided level

func OutputWithErrorLevel added in v1.1.13

func OutputWithErrorLevel(str string)

OutputWithErrorLevel is a wrapper for OutputWithCustomErrorLevel, which sets global var errorLevel to 1

func OutputWithErrorLevelf added in v1.1.13

func OutputWithErrorLevelf(format string, a ...interface{})

OutputWithErrorLevelf is a wrapper for OutputWithCustomErrorLevelf, which sets global var errorLevel to 1

func ParseOutputFlag added in v1.1.13

func ParseOutputFlag(flag string) (name, arg string)

func SetOutputExit

func SetOutputExit(e func(code int)) func(code int)

func Table

func Table(rows []*OrderedFields) error

Table takes an array of mapped fields (key being lowercased name), and outputs a table

func Template

func Template(t string, i interface{}) error

Template will format i with given Golang template t, and output resulting string to stdout

func Value

func Value(rows []*OrderedFields) error

Value will format specified rows using given includeProperties by extracting field values, and output them to stdout

Types

type DebugLogger

type DebugLogger struct {
}

func (*DebugLogger) Debug

func (l *DebugLogger) Debug(msg string)

func (*DebugLogger) Error

func (l *DebugLogger) Error(msg string)

func (*DebugLogger) Info

func (l *DebugLogger) Info(msg string)

func (*DebugLogger) Trace

func (l *DebugLogger) Trace(msg string)

func (*DebugLogger) Warn

func (l *DebugLogger) Warn(msg string)

type FieldHandlerFunc added in v1.1.13

type FieldHandlerFunc func(v *OrderedFields, fieldName string, reflectedValue reflect.Value) *OrderedFields

type FieldValue

type FieldValue struct {
	Value   string
	Default bool
}

FieldValue holds the value for a table field

func NewFieldValue

func NewFieldValue(value string, def bool) FieldValue

NewFieldValue returns a new, initialized FieldValue struct

type GenericOutputHandlerDataProvider added in v1.4.0

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

func NewGenericOutputHandlerDataProvider added in v1.4.0

func NewGenericOutputHandlerDataProvider(opts ...OutputHandlerDataProviderOption) *GenericOutputHandlerDataProvider

func (*GenericOutputHandlerDataProvider) GetData added in v1.4.0

func (p *GenericOutputHandlerDataProvider) GetData() interface{}

func (*GenericOutputHandlerDataProvider) GetFieldData added in v1.4.0

func (p *GenericOutputHandlerDataProvider) GetFieldData() ([]*OrderedFields, error)

type OrderedFields

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

OrderedFields holds a string map with field values, and a slice of keys for maintaining order

func NewOrderedFields

func NewOrderedFields() *OrderedFields

NewOrderedFields returns a pointer to an initialized OrderedFields struct

func (*OrderedFields) Exists

func (o *OrderedFields) Exists(k string) bool

Exists returns true if given key k exists, otherwise false

func (*OrderedFields) Get

func (o *OrderedFields) Get(k string) FieldValue

Get retrieves FieldValue for given key k

func (*OrderedFields) Keys

func (o *OrderedFields) Keys() []string

Keys returns a list of ordered keys

func (*OrderedFields) Set

func (o *OrderedFields) Set(k string, v FieldValue)

Set adds/updates given key k with FieldValue v

type OutputHandler added in v1.1.13

type OutputHandler struct {
	Format           string
	FormatArg        string
	Properties       []string
	SupportedFormats []string
	DataProvider     OutputHandlerDataProvider
}

func NewOutputHandler added in v1.1.13

func NewOutputHandler(dataProvider OutputHandlerDataProvider, format string, formatArg string) *OutputHandler

func (*OutputHandler) Handle added in v1.1.13

func (o *OutputHandler) Handle() error

Handle calls the relevant OutputProvider data retrieval methods for given value in struct property 'Format'

func (*OutputHandler) WithSupportedFormats added in v1.4.0

func (o *OutputHandler) WithSupportedFormats(formats []string) *OutputHandler

type OutputHandlerDataProvider added in v1.4.0

type OutputHandlerDataProvider interface {
	GetData() interface{}
	GetFieldData() ([]*OrderedFields, error)
}

type OutputHandlerDataProviderOption added in v1.4.0

type OutputHandlerDataProviderOption func(p *GenericOutputHandlerDataProvider)

func WithData added in v1.1.13

func WithData(data interface{}) OutputHandlerDataProviderOption

func WithFieldDataFunc added in v1.1.13

func WithFieldDataFunc(fieldDataFunc func() ([]*OrderedFields, error)) OutputHandlerDataProviderOption

type OutputHandlerOpts added in v1.1.13

type OutputHandlerOpts map[string]interface{}

type SerializedOutputHandlerDataProvider added in v1.4.0

type SerializedOutputHandlerDataProvider struct {
	*GenericOutputHandlerDataProvider
	// contains filtered or unexported fields
}

func NewSerializedOutputHandlerDataProvider added in v1.4.0

func NewSerializedOutputHandlerDataProvider(items interface{}) *SerializedOutputHandlerDataProvider

func (*SerializedOutputHandlerDataProvider) GetFieldData added in v1.4.0

func (*SerializedOutputHandlerDataProvider) WithDefaultFields added in v1.4.0

func (*SerializedOutputHandlerDataProvider) WithFieldHandler added in v1.4.0

func (*SerializedOutputHandlerDataProvider) WithIgnoredFields added in v1.4.0

func (*SerializedOutputHandlerDataProvider) WithMonetaryFields added in v1.4.0

func (*SerializedOutputHandlerDataProvider) WithMultipleFieldHandler added in v1.4.0

Jump to

Keyboard shortcuts

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