Documentation ¶
Index ¶
- Constants
- func Colorize(message string, colors string) string
- func Truncate(text string, lenght int) string
- type Command
- type Context
- func (c *Context) ContextFormat(tmpl *template.Template, subContext SubContext) error
- func (c *Context) ParseFormat() (*template.Template, error)
- func (c *Context) PostFormat(tmpl *template.Template, subContext SubContext)
- func (c *Context) PreFormat()
- func (c *Context) Write(sub SubContext, f SubFormat) error
- type Format
- type HeaderContext
- type SubContext
- type SubFormat
- type SubHeaderContext
Constants ¶
const ( TableFormatKey = "table" RawFormatKey = "raw" PrettyFormatKey = "pretty" JSONFormatKey = "json" DefaultQuietFormat = "{{.ID}}" ListCommandKey = "list" // default header use accross multiple formatter // UniverseHeader UniversesHeader = "Universes" // DescriptionHeader DescriptionHeader = "Description" // NameHeader NameHeader = "Name" // RegionsHeader RegionsHeader = "Regions" // StateHeader StateHeader = "State" // ProviderHeader ProviderHeader = "Provider" // StorageConfigurationHeader StorageConfigurationHeader = "Storage Configuration" // CodeHeader CodeHeader = "Code" // UUIDHeader UUIDHeader = "UUID" // StatusHeader StatusHeader = "Status" // InUseHeader InUseHeader = "In Use" // KMSConfigHeader KMSConfigHeader = "KMS configuration" // CreateTimeHeader to display create time CreateTimeHeader = "Create Time" // UpdateTimeHeader to display update time UpdateTimeHeader = "Update Time" // TypeHeader to display type TypeHeader = "Type" // GreenColor for colored output GreenColor = "green" // RedColor for colored output RedColor = "red" // BlueColor for colored output BlueColor = "blue" // YellowColor for colored output YellowColor = "yellow" )
Format keys used to specify certain kinds of output formats
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command string
Command represets the type of command being executed
func (Command) IsListCommand ¶
IsListCommand returns true if the command is a list command
type Context ¶
type Context struct { // Output is the output stream to which the formatted string is written. Output io.Writer // Format is used to choose raw, table or custom format for the output. Format Format // Command is the command being executed Command Command // ContextHeader to avoid ambiguity between HeaderContext.Header and Context.Header ContextHeader interface{} // Buffer Buffer *bytes.Buffer // contains filtered or unexported fields }
Context contains information required by the formatter to print the output as desired.
func (*Context) ContextFormat ¶
func (c *Context) ContextFormat(tmpl *template.Template, subContext SubContext) error
ContextFormat function
func (*Context) ParseFormat ¶
ParseFormat function
func (*Context) PostFormat ¶
func (c *Context) PostFormat(tmpl *template.Template, subContext SubContext)
PostFormat function
type Format ¶
type Format string
Format is the format string rendered using the Context
func (Format) IsPrettyJSON ¶
IsPrettyJSON returns true if the format is the json format
type HeaderContext ¶
type HeaderContext struct {
Header interface{}
}
HeaderContext provides the subContext interface for managing headers
func (*HeaderContext) FullHeader ¶
func (c *HeaderContext) FullHeader() interface{}
FullHeader returns the header as an interface
type SubContext ¶
type SubContext interface {
FullHeader() interface{}
}
SubContext defines what Context implementation should provide
type SubFormat ¶
type SubFormat func(func(SubContext) error) error
SubFormat is a function type accepted by Write()
type SubHeaderContext ¶
SubHeaderContext is a map destined to formatter header (table format)
func (SubHeaderContext) Label ¶
func (c SubHeaderContext) Label(name string) string
Label returns the header label for the specified string