Documentation
¶
Index ¶
- func AddFlag(cmd *cobra.Command, options ...Option)
- type FieldFn
- type Option
- type Opts
- type Table
- func (o *Table[T]) AddAllowedFields(obj T) *Table[T]
- func (o *Table[T]) AddFieldAlias(field, alias string) *Table[T]
- func (o *Table[T]) AddFieldFn(field string, fn FieldFn[T]) *Table[T]
- func (o *Table[T]) Columns() (cols []string)
- func (o *Table[T]) Flush() error
- func (o *Table[T]) RemoveAllowedField(fields ...string) *Table[T]
- func (o *Table[T]) ToAny() *Table[any]
- func (o *Table[T]) ValidateColumns(cols []string) error
- func (o *Table[T]) Write(columns []string, obj T)
- func (o *Table[T]) WriteHeader(columns []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶ added in v1.41.0
func OptionColumns ¶
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
func FlagsForCommand ¶
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
Table is a generic way to format object as a table.
func (*Table[T]) AddAllowedFields ¶
AddAllowedFields reads all first level fieldnames of the struct and allows them to be used.
func (*Table[T]) AddFieldAlias ¶
AddFieldAlias overrides the field name to allow custom column headers.
func (*Table[T]) AddFieldFn ¶
AddFieldFn adds a function which handles the output of the specified field.
func (*Table[T]) RemoveAllowedField ¶
RemoveAllowedField removes fields from the allowed list.
func (*Table[T]) ValidateColumns ¶
ValidateColumns returns an error if invalid columns are specified.
func (*Table[T]) WriteHeader ¶
WriteHeader writes the table header.
Click to show internal directories.
Click to hide internal directories.