Documentation
¶
Overview ¶
Package view provides output formatting for cfl commands.
Index ¶
- func Truncate(s string, maxLen int) string
- func ValidFormats() []string
- func ValidateFormat(format string) error
- type Format
- type ListMeta
- type ListResponse
- type Renderer
- func (r *Renderer) Error(msg string)
- func (r *Renderer) RenderJSON(v interface{}) error
- func (r *Renderer) RenderKeyValue(key, value string)
- func (r *Renderer) RenderList(headers []string, rows [][]string, hasMore bool)
- func (r *Renderer) RenderTable(headers []string, rows [][]string)
- func (r *Renderer) RenderText(text string)
- func (r *Renderer) SetWriter(w io.Writer)
- func (r *Renderer) Success(msg string)
- func (r *Renderer) Warning(msg string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidFormats ¶
func ValidFormats() []string
ValidFormats returns the list of valid output formats.
func ValidateFormat ¶
ValidateFormat checks if a format string is valid. Returns an error if the format is not supported.
Types ¶
type ListResponse ¶
type ListResponse struct {
Results []map[string]string `json:"results"`
Meta ListMeta `json:"_meta"`
}
ListResponse wraps list results with metadata for JSON output.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders data in a specific format.
func NewRenderer ¶
NewRenderer creates a new renderer with the specified format.
func (*Renderer) RenderJSON ¶
RenderJSON renders an object as JSON.
func (*Renderer) RenderKeyValue ¶
RenderKeyValue renders a key-value pair.
func (*Renderer) RenderList ¶
RenderList renders tabular data with pagination metadata. For JSON output, wraps results in an object with _meta field. For other formats, delegates to RenderTable.
func (*Renderer) RenderTable ¶
RenderTable renders data as a table.
func (*Renderer) RenderText ¶
RenderText renders plain text.