Documentation
¶
Overview ¶
Package output formats API responses for the CLI.
Index ¶
- func ApplyQuery(data interface{}, expr string) (interface{}, error)
- func EncodeJSON(data interface{}) ([]byte, error)
- func Write(w io.Writer, format Format, data interface{}) error
- func WriteWithOptions(w io.Writer, format Format, data interface{}, opts Options) error
- type Format
- type Options
- type Query
- type QueryError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyQuery ¶
ApplyQuery evaluates a JMESPath expression against data. Empty expr returns data unchanged.
func EncodeJSON ¶
EncodeJSON returns indented JSON with HTML escaping disabled.
Types ¶
type Format ¶
type Format string
Format is a supported --output value.
func ParseFormat ¶
ParseFormat normalizes and validates an --output value. Empty string defaults to json.
type Options ¶
type Options struct {
// Columns is the preferred column order for table/text. It is applied only
// when it exactly matches the keys present in the data; otherwise renderers
// keep alphabetical order. See column_order.go.
Columns []string
// TerminalWidth caps table width. 0 means "detect from stdout"; a negative
// value disables fitting entirely (useful for tests and for piped output
// that should keep full-width columns).
TerminalWidth int
// Color enables ANSI styling for table headers and cells. Styling never
// affects column widths; see style.go.
Color bool
}
Options carries rendering hints that do not change the data itself.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a validated JMESPath expression.
func CompileQuery ¶
CompileQuery validates expr before an API request is sent. Empty expressions do not require a query.
type QueryError ¶
type QueryError struct {
Expression string
Offset int // byte offset of the failure; -1 when unknown
Err error
}
QueryError explains why an expression failed to compile.
func (*QueryError) Error ¶
func (e *QueryError) Error() string
func (*QueryError) Unwrap ¶
func (e *QueryError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.