Documentation ¶
Index ¶
- func BoolFormat(val interface{}) (text.Colors, string, error)
- func Render(writer io.Writer, cfg *config.Config, commandOutputs ...Output) (err error)
- type Combined
- type CombinedSection
- type DetailRow
- type DetailSection
- type Details
- type Error
- type MarshaledWithHumanDetails
- type None
- type OnlyMarshaled
- type Output
- type Raw
- type Table
- type TableColumn
- type TableRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolFormat ¶
BoolFormat returns val formatted as a boolean
Types ¶
type Combined ¶
type Combined []CombinedSection
Combined represents multiple outputs combined and displayed sequentially (or wrapped into the same object)
func (Combined) MarshalHuman ¶
MarshalHuman returns output in a human-readable form
func (Combined) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (Combined) MarshalRawMap ¶
MarshalRawMap implements output.Output
func (Combined) MarshalYAML ¶
MarshalYAML returns table output marshaled to YAML.
type CombinedSection ¶
CombinedSection represents a single section of a combined output
type DetailRow ¶
type DetailRow struct { Title string // used for human-readable representations Key string // user for machine-readable (json, yaml) representations Value interface{} Colour text.Colors Format func(val interface{}) (text.Colors, string, error) }
DetailRow represents a single row in the details view, with a title and a value
type DetailSection ¶
type DetailSection struct { Title string // used for human-readable representations Key string // user for machine-readable (json, yaml) representations Rows []DetailRow }
DetailSection represents a section in the details view
func (DetailSection) MarshalJSON ¶
func (d DetailSection) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
type Details ¶
type Details struct {
Sections []DetailSection
}
Details implements output.Output for a details-style view
func (Details) MarshalHuman ¶
MarshalHuman marshals details and returns a human readable []byte
func (Details) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (Details) MarshalRawMap ¶
MarshalRawMap implements output.Output
func (Details) MarshalYAML ¶
MarshalYAML marshals details and returns the YAML as []byte nb. does *not* implement yaml.Marshaler
type Error ¶
type Error struct {
Value error
}
Error implements output.Command for a return value that is an error
func (Error) MarshalHuman ¶
MarshalHuman implements output.Output
func (Error) MarshalJSON ¶
MarshalJSON implements json.Marshaler and output.Output
func (Error) MarshalRawMap ¶
MarshalRawMap implements output.Output
func (Error) MarshalYAML ¶
MarshalYAML implements output.Output, it marshals the value and returns the YAML as []byte nb. does *not* implement yaml.Marshaler
type MarshaledWithHumanDetails ¶
type MarshaledWithHumanDetails struct { Value interface{} Details []DetailRow }
MarshaledWithHumanDetails implements output.Command for a return value that is only displayed as raw marshaled in JSON and YAML eg. most 'state change' commands
func (MarshaledWithHumanDetails) MarshalHuman ¶
func (d MarshaledWithHumanDetails) MarshalHuman() ([]byte, error)
MarshalHuman implements output.Output For MarshaledWithHumanDetails outputs, we return *only* the details part in humanized output
func (MarshaledWithHumanDetails) MarshalJSON ¶
func (d MarshaledWithHumanDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and output.Output
func (MarshaledWithHumanDetails) MarshalRawMap ¶
func (d MarshaledWithHumanDetails) MarshalRawMap() (map[string]interface{}, error)
MarshalRawMap implements output.Output
func (MarshaledWithHumanDetails) MarshalYAML ¶
func (d MarshaledWithHumanDetails) MarshalYAML() ([]byte, error)
MarshalYAML implements output.Output, it marshals the value and returns the YAML as []byte nb. does *not* implement yaml.Marshaler
type None ¶
type None struct{}
None is used when the command returns no output
func (None) MarshalHuman ¶
MarshalHuman implements output.Output
func (None) MarshalJSON ¶
MarshalJSON implements output.Output
func (None) MarshalRawMap ¶
MarshalRawMap implements output.Output
func (None) MarshalYAML ¶
MarshalYAML implements output.Output
type OnlyMarshaled ¶
type OnlyMarshaled struct {
Value interface{}
}
OnlyMarshaled implements output.Command for a return value that is only displayed as raw marshaled in JSON and YAML eg. most 'state change' commands
func (OnlyMarshaled) MarshalHuman ¶
func (d OnlyMarshaled) MarshalHuman() ([]byte, error)
MarshalHuman implements output.Output For OnlyMarshaled outputs, we dont return anything in humanized output as it's assumed the log output is what the user wants and it is down to the command itself to provide that.
func (OnlyMarshaled) MarshalJSON ¶
func (d OnlyMarshaled) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and output.Output
func (OnlyMarshaled) MarshalRawMap ¶
func (d OnlyMarshaled) MarshalRawMap() (map[string]interface{}, error)
MarshalRawMap implements output.Output
func (OnlyMarshaled) MarshalYAML ¶
func (d OnlyMarshaled) MarshalYAML() ([]byte, error)
MarshalYAML implements output.Output, it marshals the value and returns the YAML as []byte nb. does *not* implement yaml.Marshaler
type Output ¶
type Output interface { json.Marshaler MarshalYAML() ([]byte, error) MarshalHuman() ([]byte, error) MarshalRawMap() (map[string]interface{}, error) }
Output represent output from a command that can be rendered as JSON, YAML or human-readable
type Raw ¶
type Raw []byte
Raw is a way to output raw data to the user. It is *only* supported in humanized output and used for generating shell completion scripts.
func (Raw) MarshalHuman ¶
MarshalHuman implements output.Output
func (Raw) MarshalJSON ¶
MarshalJSON implements output.Output
func (Raw) MarshalRawMap ¶
MarshalRawMap implements output.Output
func (Raw) MarshalYAML ¶
MarshalYAML implements output.Output
type Table ¶
type Table struct { Columns []TableColumn Rows []TableRow HideHeader bool }
Table represents command output rendered as a table
func (Table) MarshalHuman ¶
MarshalHuman returns table output in a human-readable form
func (Table) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (Table) MarshalRawMap ¶
MarshalRawMap implements output.Output
func (Table) MarshalYAML ¶
MarshalYAML returns table output marshaled to YAML.