Documentation
¶
Index ¶
- func Truncate(s string, maxLen int) string
- func ValidateSkipHeader(skipHeader bool, format string) error
- type Column
- type Format
- type Formatter
- func (f *Formatter) Format() Format
- func (f *Formatter) Print(data interface{}) error
- func (f *Formatter) PrintCSV(columns []Column, data []interface{}) error
- func (f *Formatter) PrintJSON(data interface{}) error
- func (f *Formatter) PrintTable(columns []Column, data []interface{}) error
- func (f *Formatter) PrintYAML(data interface{}) error
- type FormatterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateSkipHeader ¶ added in v1.4.0
ValidateSkipHeader returns an error if --skip-header is used with a format that has no header row (e.g. JSON or YAML).
Types ¶
type Format ¶
type Format string
Format represents the output format type
func ParseFormat ¶
ParseFormat parses a format string into a Format type
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter handles output formatting
func NewFormatter ¶
func NewFormatter(format Format, w io.Writer, opts ...FormatterOption) *Formatter
NewFormatter creates a formatter for the specified output format
func (*Formatter) Print ¶
Print outputs data in the configured format (JSON or YAML only) For table format, use the type-specific table printing functions
func (*Formatter) PrintCSV ¶ added in v1.5.0
PrintCSV prints data as CSV using the given columns. Header values are lowercased for consistency with query CSV output.
func (*Formatter) PrintTable ¶
PrintTable prints a table with the given columns and data
type FormatterOption ¶ added in v1.4.0
type FormatterOption func(*Formatter)
FormatterOption configures optional Formatter behavior.
func WithSkipHeader ¶ added in v1.4.0
func WithSkipHeader(skip bool) FormatterOption
WithSkipHeader omits the header row from table output.