output

package
v0.0.0-...-0384855 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT, MIT Imports: 12 Imported by: 5

Documentation

Overview

Licensed under the MIT License https://opensource.org/licenses/MIT

https://github.com/hetznercloud/cli/tree/87552d2a684f7147dc0528e32915fa96dd7332ad/internal/cmd/output

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlag

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

func GetFlag

func GetFlag(cmd *cobra.Command) []string

Types

type FieldFn

type FieldFn func(obj interface{}) string

type Option

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

func OptionYAML() Option

type Opts

type Opts map[string][]string

func FlagsForCommand

func FlagsForCommand(cmd *cobra.Command) Opts

func (Opts) Add

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

func (o Opts) IsSet(key string) bool

func (Opts) Set

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