output

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package output renders API response data to Out. Human-facing commentary is internal/ui's job, not this package's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PadGrid

func PadGrid(grid [][]string) []string

Measures VISIBLE width, unlike text/tabwriter which counts escape bytes. The final column is never padded, to avoid trailing whitespace.

Types

type Format

type Format int
const (
	FormatTable Format = iota
	FormatJSON
	FormatYAML
)

func ParseFormat

func ParseFormat(s string) (Format, error)

type Options

type Options struct {
	Columns []string
	// Shown and Total drive the truncation footer. Total of 0 means unknown.
	Shown int
	Total int
	Quiet bool
}

type Result

type Result struct {
	Empty bool
}

Lets a caller that knows the resource name say something useful about an empty list; the renderer has no idea what "customers" are.

type Writer

type Writer struct {
	Out    io.Writer
	Err    io.Writer
	Format Format
}

func (Writer) Render

func (w Writer) Render(raw []byte, o Options) error

func (Writer) RenderResult

func (w Writer) RenderResult(raw []byte, o Options) (Result, error)

Empty is only reported for table output: json and yaml are machine formats where an empty list is valid output the caller must not print prose over.

func (Writer) Warn

func (w Writer) Warn(o Options, format string, args ...any)

Jump to

Keyboard shortcuts

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