output

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 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 ...outputOption)

func FlagsForCommand

func FlagsForCommand(cmd *cobra.Command) outputOpts

func OptionColumns

func OptionColumns(columns []string) outputOption

func OptionFormat

func OptionFormat() outputOption

func OptionJSON

func OptionJSON() outputOption

func OptionNoHeader

func OptionNoHeader() outputOption

Types

type FieldFn

type FieldFn func(obj interface{}) string

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