output

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlag

func AddFlag(cmd *cobra.Command, options ...Option)

Types

type FieldFn

type FieldFn func(obj interface{}) string

type Option added in v1.41.0

type Option struct {
	Name   string
	Values []string
}

func OptionColumns

func OptionColumns(columns []string) Option

func OptionFormat

func OptionFormat() Option

func OptionJSON

func OptionJSON() Option

func OptionNoHeader

func OptionNoHeader() Option

func OptionYAML added in v1.41.0

func OptionYAML() Option

type Opts added in v1.41.0

type Opts map[string][]string

func FlagsForCommand

func FlagsForCommand(cmd *cobra.Command) Opts

func (Opts) Add added in v1.41.0

func (o Opts) Add(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Opts) IsSet added in v1.41.0

func (o Opts) IsSet(key string) bool

func (Opts) Set added in v1.41.0

func (o Opts) Set(key, value string)

Set sets the key to value. It replaces any existing values.

type Table

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

Table is a generic way to format object as a table.

func NewTable

func NewTable() *Table

NewTable creates a new Table.

func (*Table) AddAllowedFields

func (o *Table) AddAllowedFields(obj interface{}) *Table

AddAllowedFields reads all first level fieldnames of the struct and allows them to be used.

func (*Table) AddFieldAlias

func (o *Table) AddFieldAlias(field, alias string) *Table

AddFieldAlias overrides the field name to allow custom column headers.

func (*Table) AddFieldFn

func (o *Table) AddFieldFn(field string, fn FieldFn) *Table

AddFieldFn adds a function which handles the output of the specified field.

func (*Table) Columns

func (o *Table) Columns() (cols []string)

Columns returns a list of known output columns.

func (*Table) Flush

func (o *Table) Flush() error

func (*Table) RemoveAllowedField

func (o *Table) RemoveAllowedField(fields ...string) *Table

RemoveAllowedField removes fields from the allowed list.

func (*Table) ValidateColumns

func (o *Table) ValidateColumns(cols []string) error

ValidateColumns returns an error if invalid columns are specified.

func (*Table) Write

func (o *Table) Write(columns []string, obj interface{})

Write writes a table line.

func (*Table) WriteHeader

func (o *Table) WriteHeader(columns []string)

WriteHeader writes the table header.

Jump to

Keyboard shortcuts

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