view

package
v0.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package view provides output formatting for cfl commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to the specified length.

func ValidFormats

func ValidFormats() []string

ValidFormats returns the list of valid output formats.

func ValidateFormat

func ValidateFormat(format string) error

ValidateFormat checks if a format string is valid. Returns an error if the format is not supported.

Types

type Format

type Format string

Format represents an output format.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatPlain Format = "plain"
)

Output format constants.

type ListMeta

type ListMeta struct {
	Count   int  `json:"count"`
	HasMore bool `json:"hasMore"`
}

ListMeta contains pagination metadata for list results.

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

func NewRenderer(format Format, noColor bool) *Renderer

NewRenderer creates a new renderer with the specified format.

func (*Renderer) Error

func (r *Renderer) Error(msg string)

Error prints an error message.

func (*Renderer) RenderJSON

func (r *Renderer) RenderJSON(v interface{}) error

RenderJSON renders an object as JSON.

func (*Renderer) RenderKeyValue

func (r *Renderer) RenderKeyValue(key, value string)

RenderKeyValue renders a key-value pair.

func (*Renderer) RenderList

func (r *Renderer) RenderList(headers []string, rows [][]string, hasMore bool)

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

func (r *Renderer) RenderTable(headers []string, rows [][]string)

RenderTable renders data as a table.

func (*Renderer) RenderText

func (r *Renderer) RenderText(text string)

RenderText renders plain text.

func (*Renderer) SetWriter

func (r *Renderer) SetWriter(w io.Writer)

SetWriter sets the output writer.

func (*Renderer) Success

func (r *Renderer) Success(msg string)

Success prints a success message.

func (*Renderer) Warning

func (r *Renderer) Warning(msg string)

Warning prints a warning message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL