Documentation ¶
Index ¶
- Variables
- func CSV(rows []*OrderedFields) error
- func CommandOutput(cmd *cobra.Command, out OutputHandlerDataProvider) error
- func CommandOutputPaginated[T any](cmd *cobra.Command, out OutputHandlerDataProvider, ...) error
- func Error(str string)
- func Errorf(format string, a ...interface{})
- func ExitWithErrorLevel()
- func Fatal(str string)
- func Fatalf(format string, a ...interface{})
- func JSON(v interface{}) error
- func JSONPath(query string, v interface{}) error
- func List(rows []*OrderedFields) error
- func OutputWithCustomErrorLevel(level int, str string)
- func OutputWithCustomErrorLevelf(level int, format string, a ...interface{})
- func OutputWithErrorLevel(str string)
- func OutputWithErrorLevelf(format string, a ...interface{})
- func ParseOutputFlag(flag string) (name, arg string)
- func SetOutputExit(e func(code int)) func(code int)
- func Table(rows []*OrderedFields) error
- func Template(t string, i interface{}) error
- func Value(rows []*OrderedFields) error
- func YAML(v interface{}) error
- type DebugLogger
- type FieldHandlerFunc
- type FieldValue
- type FieldValueHandlerFunc
- type GenericOutputHandlerDataProvider
- type OrderedFields
- type OutputHandler
- type OutputHandlerDataProvider
- type OutputHandlerDataProviderOption
- type OutputHandlerOpts
- type SerializedOutputHandlerDataProvider
- func (o *SerializedOutputHandlerDataProvider) GetFieldData() ([]*OrderedFields, error)
- func (o *SerializedOutputHandlerDataProvider) WithDefaultFields(fields []string) *SerializedOutputHandlerDataProvider
- func (o *SerializedOutputHandlerDataProvider) WithFieldHandler(f FieldHandlerFunc, fieldNames ...string) *SerializedOutputHandlerDataProvider
- func (o *SerializedOutputHandlerDataProvider) WithFieldValueHandler(f FieldValueHandlerFunc, fieldNames ...string) *SerializedOutputHandlerDataProvider
- func (o *SerializedOutputHandlerDataProvider) WithIgnoredFields(fields []string) *SerializedOutputHandlerDataProvider
- func (o *SerializedOutputHandlerDataProvider) WithMonetaryFields(fields []string) *SerializedOutputHandlerDataProvider
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CommandOutput ¶
func CommandOutput(cmd *cobra.Command, out OutputHandlerDataProvider) error
func CommandOutputPaginated ¶
func CommandOutputPaginated[T any](cmd *cobra.Command, out OutputHandlerDataProvider, paginated *connection.Paginated[T]) error
func Errorf ¶
func Errorf(format string, a ...interface{})
Errorf writes specified string with formatting to stderr
func ExitWithErrorLevel ¶
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 List ¶
func List(rows []*OrderedFields) error
List will format specified rows using given includeProperties by extracting fields, and output them to stdout
func OutputWithCustomErrorLevel ¶
OutputWithCustomErrorLevel is a wrapper for OutputError, which sets global var errorLevel with provided level
func OutputWithCustomErrorLevelf ¶
OutputWithCustomErrorLevelf is a wrapper for OutputWithCustomErrorLevel, which sets global var errorLevel with provided level
func OutputWithErrorLevel ¶
func OutputWithErrorLevel(str string)
OutputWithErrorLevel is a wrapper for OutputWithCustomErrorLevel, which sets global var errorLevel to 1
func OutputWithErrorLevelf ¶
func OutputWithErrorLevelf(format string, a ...interface{})
OutputWithErrorLevelf is a wrapper for OutputWithCustomErrorLevelf, which sets global var errorLevel to 1
func ParseOutputFlag ¶
func SetOutputExit ¶
func Table ¶
func Table(rows []*OrderedFields) error
Table takes an array of mapped fields (key being lowercased name), and outputs a table
func Template ¶
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 ¶
type FieldHandlerFunc func(v *OrderedFields, fieldName string, reflectedValue reflect.Value) *OrderedFields
type FieldValue ¶
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 FieldValueHandlerFunc ¶
type GenericOutputHandlerDataProvider ¶
type GenericOutputHandlerDataProvider struct {
// contains filtered or unexported fields
}
func NewGenericOutputHandlerDataProvider ¶
func NewGenericOutputHandlerDataProvider(opts ...OutputHandlerDataProviderOption) *GenericOutputHandlerDataProvider
func (*GenericOutputHandlerDataProvider) GetData ¶
func (p *GenericOutputHandlerDataProvider) GetData() interface{}
func (*GenericOutputHandlerDataProvider) GetFieldData ¶
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 ¶
type OutputHandler struct { Format string FormatArg string Properties []string SupportedFormats []string DataProvider OutputHandlerDataProvider }
func NewOutputHandler ¶
func NewOutputHandler(dataProvider OutputHandlerDataProvider, format string, formatArg string) *OutputHandler
func (*OutputHandler) Handle ¶
func (o *OutputHandler) Handle() error
Handle calls the relevant OutputProvider data retrieval methods for given value in struct property 'Format'
func (*OutputHandler) WithSupportedFormats ¶
func (o *OutputHandler) WithSupportedFormats(formats []string) *OutputHandler
type OutputHandlerDataProvider ¶
type OutputHandlerDataProvider interface { GetData() interface{} GetFieldData() ([]*OrderedFields, error) }
type OutputHandlerDataProviderOption ¶
type OutputHandlerDataProviderOption func(p *GenericOutputHandlerDataProvider)
func WithData ¶
func WithData(data interface{}) OutputHandlerDataProviderOption
func WithFieldDataFunc ¶
func WithFieldDataFunc(fieldDataFunc func() ([]*OrderedFields, error)) OutputHandlerDataProviderOption
type OutputHandlerOpts ¶
type OutputHandlerOpts map[string]interface{}
type SerializedOutputHandlerDataProvider ¶
type SerializedOutputHandlerDataProvider struct { *GenericOutputHandlerDataProvider // contains filtered or unexported fields }
func NewSerializedOutputHandlerDataProvider ¶
func NewSerializedOutputHandlerDataProvider(items interface{}) *SerializedOutputHandlerDataProvider
func (*SerializedOutputHandlerDataProvider) GetFieldData ¶
func (o *SerializedOutputHandlerDataProvider) GetFieldData() ([]*OrderedFields, error)
func (*SerializedOutputHandlerDataProvider) WithDefaultFields ¶
func (o *SerializedOutputHandlerDataProvider) WithDefaultFields(fields []string) *SerializedOutputHandlerDataProvider
func (*SerializedOutputHandlerDataProvider) WithFieldHandler ¶
func (o *SerializedOutputHandlerDataProvider) WithFieldHandler(f FieldHandlerFunc, fieldNames ...string) *SerializedOutputHandlerDataProvider
func (*SerializedOutputHandlerDataProvider) WithFieldValueHandler ¶
func (o *SerializedOutputHandlerDataProvider) WithFieldValueHandler(f FieldValueHandlerFunc, fieldNames ...string) *SerializedOutputHandlerDataProvider
func (*SerializedOutputHandlerDataProvider) WithIgnoredFields ¶
func (o *SerializedOutputHandlerDataProvider) WithIgnoredFields(fields []string) *SerializedOutputHandlerDataProvider
func (*SerializedOutputHandlerDataProvider) WithMonetaryFields ¶
func (o *SerializedOutputHandlerDataProvider) WithMonetaryFields(fields []string) *SerializedOutputHandlerDataProvider