Documentation ¶
Overview ¶
Package formatter contains the logic to template the CLI output to a specific format
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetLoaderFunc ¶
AssetLoaderFunc loads and returns the asset for the given name. If an error is returned, the asset could not be found or could not be loaded.
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain implements the Chain interface
Allows the formatting responsibility to become a chain. It will cascade when formatter.Format returns an error and the next property contains another actionable chain (next != nil). When the Format is handled without error it will return immediately
func New ¶
New initializes a ChainFormatter defaulting to the JSON Formatter if no known formatter is passed, else It will use the mentioned formatter and use the JSON Formatter to fallback when parsing the output fails.
type Chainer ¶
type Chainer interface { Formatter // Add adds a the next ChainFormatter to the chain Add(Chainer) *Chain }
Chainer implements the Single Chain of Responsibility Pattern, to be able to chain off multiple Formatters
type Formatter ¶
type Formatter interface { // Format is used from the cmd, it receives the parent and the data to be // formatted. The path usually has an effect on how the data will end up // being represented. Format(path string, data interface{}) error // Name obtains the name of the Formatter Name() string }
Formatter models the formatter actions
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
JSON formats into text
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text formats into text
type TextConfig ¶
type TextConfig struct { // Output device where the template execution will be written. Output io.Writer // Override is the format to be used for the commands that are sent Override string // Fallback base template to use when a file asset is not found in // "text/parent/child.gotmpl" unless specified `defaultOverrideFormat` is // used. Fallback string // Padding represents the number of spaces to use in between the text // columns. Padding int // AssetLoaderFunction is the asset loader function to be used. It must // return a byte encoded Go template parseable by template.Template.Parse. AssetLoaderFunction AssetLoaderFunc }
TextConfig is the configuration to use for a text formatter