Documentation ¶
Index ¶
- func Flatten(obj map[string]interface{}, t []TemplateItem) []interface{}
- func GetLabels(items []TemplateItem) []interface{}
- func GetValue(m map[string]interface{}, path string) (error, interface{})
- type CSVPrinter
- type CSVPrinterOptions
- type JSONPrinter
- type JSONPrinterOptions
- type Printer
- type TemplateItem
- type WidePrinter
- type WidePrinterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Flatten ¶ added in v0.1.3
func Flatten(obj map[string]interface{}, t []TemplateItem) []interface{}
Flatten an object using the template.
func GetLabels ¶ added in v0.1.3
func GetLabels(items []TemplateItem) []interface{}
Converts TemplateItems to an array of label.
Types ¶
type CSVPrinter ¶
type CSVPrinter struct { // Options of CSV format. Options CSVPrinterOptions // contains filtered or unexported fields }
A Printer which output values as a CSV format.
func (*CSVPrinter) Flush ¶
func (p *CSVPrinter) Flush()
Flush data in the buffer. This function must be called to output all data.
func (*CSVPrinter) Write ¶
func (p *CSVPrinter) Write(r []interface{})
Format and write fields represented as an array.
func (*CSVPrinter) WriteHeader ¶ added in v0.1.3
func (p *CSVPrinter) WriteHeader(t []TemplateItem)
Write a header.
func (*CSVPrinter) WriteWithTemplate ¶ added in v0.1.3
func (p *CSVPrinter) WriteWithTemplate(r []map[string]interface{}, t []TemplateItem)
Write fields with the template.
type CSVPrinterOptions ¶
type CSVPrinterOptions struct { Out io.Writer // A string that represents end of line. CRLF string // Date format used to convert time.Time to string. DateFormat string // CSVPrinter quote the string value if QuoteString is true. QuoteString bool // Separator between columns. Separator string }
A set of options used for CSV format.
func NewCSVPrinterOptions ¶
func NewCSVPrinterOptions(output io.Writer) CSVPrinterOptions
Create a CSVPrinterOptions with default values set.
type JSONPrinter ¶ added in v0.1.3
type JSONPrinter struct { // Options of JSON format. Options JSONPrinterOptions // contains filtered or unexported fields }
func NewJSONPrinter ¶ added in v0.1.3
func NewJSONPrinter(o JSONPrinterOptions) *JSONPrinter
func (*JSONPrinter) Flush ¶ added in v0.1.3
func (p *JSONPrinter) Flush()
func (*JSONPrinter) Write ¶ added in v0.1.3
func (p *JSONPrinter) Write(r []interface{})
func (*JSONPrinter) WriteHeader ¶ added in v0.1.3
func (p *JSONPrinter) WriteHeader(t []TemplateItem)
Write a header
func (*JSONPrinter) WriteWithTemplate ¶ added in v0.1.3
func (p *JSONPrinter) WriteWithTemplate(r []map[string]interface{}, t []TemplateItem)
Write fields with the template. Prefer use of json encode then indent over marshalIndent to prevent HTML escaping, which causes invalid URLs to be printed.
type JSONPrinterOptions ¶ added in v0.1.3
func NewJSONPrinterOptions ¶ added in v0.1.3
func NewJSONPrinterOptions(output io.Writer) JSONPrinterOptions
type Printer ¶
type Printer interface { // Write buffered data to the underlying io.Writer. Flush() // Write an object represented as an array. Write(r []interface{}) // Write a header. WriteHeader(t []TemplateItem) // Write an object with a template. WriteWithTemplate(r []map[string]interface{}, t []TemplateItem) }
Printer is the interface to output values.
type TemplateItem ¶ added in v0.1.3
type WidePrinter ¶
type WidePrinter struct { Options WidePrinterOptions // contains filtered or unexported fields }
func NewWidePrinter ¶
func NewWidePrinter(o WidePrinterOptions) *WidePrinter
Create a new WidePrinter.
func (*WidePrinter) Flush ¶
func (p *WidePrinter) Flush()
Flush data in the buffer. This function must be called to output all data.
func (*WidePrinter) Write ¶
func (p *WidePrinter) Write(r []interface{})
Format and write fields represented as an array.
func (*WidePrinter) WriteHeader ¶ added in v0.1.3
func (p *WidePrinter) WriteHeader(t []TemplateItem)
Write a header.
func (*WidePrinter) WriteWithTemplate ¶ added in v0.1.3
func (p *WidePrinter) WriteWithTemplate(r []map[string]interface{}, t []TemplateItem)
Write fields with the template.
type WidePrinterOptions ¶
type WidePrinterOptions struct { Out io.Writer CRLF string DateFormat string Flags uint MinWidth int TabWidth int Padding int PadChar byte }
func NewWidePrinterOptions ¶
func NewWidePrinterOptions(output io.Writer) WidePrinterOptions
Create a WidePrinterOptions with default values set.