Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFormatType = fmt.Errorf("invalid format type")
ErrInvalidFormatType is returned when an unsupported format type is used
Functions ¶
func EncodeJSON ¶
func EncodeJSON(out io.Writer, obj interface{}) error
EncodeJSON is a helper function to decorate any error message with a bit more context and avoid writing the same code over and over for printers.
func EncodeTable ¶
func EncodeTable(out io.Writer, table *uitable.Table) error
EncodeTable is a helper function to decorate any error message with a bit more context and avoid writing the same code over and over for printers
func EncodeYAML ¶
func EncodeYAML(out io.Writer, obj interface{}) error
EncodeYAML is a helper function to decorate any error message with a bit more context and avoid writing the same code over and over for printers
Types ¶
type Format ¶
type Format string
Format is a type for capturing supported output formats
const (
// Table format
Table Format = "table"
// JSON Format
JSON Format = "json"
// YAML Format
YAML Format = "yaml"
)
func ParseFormat ¶
func ParseFormat(s string) (out Format, err error)
ParseFormat takes a raw string and returns the matching Format. If the format does not exists, ErrInvalidFormatType is returned
type Writer ¶
type Writer interface {
// WriteTable will write tabular output into the given io.Writer, returning
// an error if any occur
WriteTable(out io.Writer) error
// WriteJSON will write JSON formatted output into the given io.Writer,
// returning an error if any occur
WriteJSON(out io.Writer) error
// WriteYAML will write YAML formatted output into the given io.Writer,
// returning an error if any occur
WriteYAML(out io.Writer) error
}
Writer is an interface that any type can implement to write supported formats