output

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MonetaryFieldValueHandler = func(reflectedValue reflect.Value) string {
	return fmt.Sprintf("%.2f", reflectedValue.Float())
}

Functions

func CommandOutput

func CommandOutput(cmd *cobra.Command, d interface{}, opts ...OutputHandlerOption) error

func CommandOutputPaginated

func CommandOutputPaginated[T any](cmd *cobra.Command, d interface{}, paginated *connection.Paginated[T]) 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

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 OutputWithCustomErrorLevel

func OutputWithCustomErrorLevel(level int, str string)

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

func OutputWithCustomErrorLevelf

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

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 ParseOutputFlag(flag string) (name, arg string)

func SetOutputExit

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

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 DefaultColumnable added in v1.23.0

type DefaultColumnable interface {
	DefaultColumns() []string
}

type FieldValueHandlerFunc

type FieldValueHandlerFunc func(reflectedValue reflect.Value) string

type HandlesFields added in v1.23.0

type HandlesFields interface {
	FieldValueHandlers() map[string]FieldValueHandlerFunc
}

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) string

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 string)

Set adds/updates given key k with FieldValue v

type OutputHandler

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

func NewOutputHandler

func NewOutputHandler(opts ...OutputHandlerOption) *OutputHandler

func (*OutputHandler) CSV added in v1.23.0

func (o *OutputHandler) CSV(cmd *cobra.Command, d interface{}) error

CSV outputs provided rows as CSV to stdout

func (*OutputHandler) JSON added in v1.23.0

func (o *OutputHandler) JSON(d interface{}, pretty bool) error

func (*OutputHandler) JSONPath added in v1.23.0

func (o *OutputHandler) JSONPath(query string, d interface{}) error

JSONPath marshals and outputs value v to stdout

func (*OutputHandler) List added in v1.23.0

func (o *OutputHandler) List(cmd *cobra.Command, d interface{}) error

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

func (*OutputHandler) Output added in v1.23.0

func (o *OutputHandler) Output(cmd *cobra.Command, d interface{}) error

func (*OutputHandler) Table added in v1.23.0

func (o *OutputHandler) Table(cmd *cobra.Command, d interface{}) error

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

func (*OutputHandler) Template added in v1.23.0

func (o *OutputHandler) Template(t string, d interface{}) error

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

func (*OutputHandler) Value added in v1.23.0

func (o *OutputHandler) Value(cmd *cobra.Command, d interface{}) error

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

func (*OutputHandler) YAML added in v1.23.0

func (o *OutputHandler) YAML(d interface{}) error

YAML marshals and outputs value v to stdout

type OutputHandlerOption added in v1.26.0

type OutputHandlerOption func(*OutputHandler)

func WithAdditionalColumns added in v1.26.0

func WithAdditionalColumns(columns ...string) OutputHandlerOption

type OutputHandlerOpts

type OutputHandlerOpts map[string]interface{}

type ProvidesFields added in v1.23.0

type ProvidesFields interface {
	Fields() []*OrderedFields
}

Jump to

Keyboard shortcuts

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