renderer

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: BSD-3-Clause, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render added in v1.5.4

func Render(data []ResponseData)

Render renders the data using the appropriate renderer

func RenderStatic added in v1.6.3

func RenderStatic(data []ResponseData)

RenderStatic renders data without the interactive table.

func ValidateOutputSelection added in v1.6.3

func ValidateOutputSelection() error

ValidateOutputSelection checks the output-related flags up front so commands fail fast with a clear message (and a non-zero exit) instead of silently falling back or erroring deep in the render path. It rejects an unknown --output value, a --query used with a non-structured format, and a malformed JMESPath expression.

Types

type BubbleTeaRenderer added in v1.5.4

type BubbleTeaRenderer struct{}

BubbleTeaRenderer renders ResponseData using Bubble Tea

func (BubbleTeaRenderer) Render added in v1.5.4

func (btr BubbleTeaRenderer) Render(data []ResponseData)

type CSVRenderer added in v1.6.3

type CSVRenderer struct{}

func (CSVRenderer) Render added in v1.6.3

func (cr CSVRenderer) Render(data []ResponseData)

type Format added in v1.6.3

type Format string

Format is the output format selected for a command's results. table is the human-facing default; json, yaml and csv are the machine-readable formats meant for automation, piping and (in the future) an MCP server.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatYAML  Format = "yaml"
	FormatCSV   Format = "csv"
)

func ParseFormat added in v1.6.3

func ParseFormat(s string) (Format, bool)

ParseFormat normalizes a user-supplied format string. ok is false for an unrecognized value so callers can surface an actionable error.

func ResolveFormat added in v1.6.3

func ResolveFormat() Format

ResolveFormat determines the active output format.

Precedence: an explicit --output flag > --json shortcut > env (LSH_OUTPUT) > config > default. An explicit --output always wins — including -o table over --json — which is why callers record whether the flag was set via the "output_explicit" key (viper.GetString alone can't tell an explicit `-o table` from the "table" default).

func (Format) IsStructured added in v1.6.3

func (f Format) IsStructured() bool

IsStructured reports whether the format produces machine-readable, queryable output. Only structured formats support the --query (JMESPath) flag.

type JSONRenderer

type JSONRenderer struct{}

func (JSONRenderer) Render

func (jr JSONRenderer) Render(data []ResponseData)

type Renderer

type Renderer interface {
	Render(data []ResponseData)
}

func GetRenderer added in v1.5.4

func GetRenderer() Renderer

GetRenderer returns the renderer for the active output format.

Structured formats (json/yaml/csv) are honored everywhere, including when stdout is piped — that is the whole point of automation output. The table format additionally chooses between the classic ASCII writer (for CI / LSH_CLASSIC_OUTPUT / non-TTY pipes) and the interactive Bubble Tea view.

func GetStaticRenderer added in v1.6.3

func GetStaticRenderer() Renderer

GetStaticRenderer is like GetRenderer but never returns the interactive Bubble Tea view. Use it for flows where taking over the terminal is wrong — e.g. a `--wait` that must print the resource and then keep streaming progress.

type ResponseData

type ResponseData interface {
	TableRow() outputTable.Row
}

type TableRenderer

type TableRenderer struct{}

func (TableRenderer) Render

func (tr TableRenderer) Render(data []ResponseData)

type YAMLRenderer added in v1.6.3

type YAMLRenderer struct{}

func (YAMLRenderer) Render added in v1.6.3

func (yr YAMLRenderer) Render(data []ResponseData)

Jump to

Keyboard shortcuts

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