output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	Format(w io.Writer, data any) error
}

Formatter writes structured data to output.

func NewFormatter

func NewFormatter(mode OutputMode) Formatter

NewFormatter creates a formatter for the given mode.

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter outputs pretty-printed JSON.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(w io.Writer, data any) error

type OutputMode

type OutputMode int

OutputMode selects the output format.

const (
	ModeTable OutputMode = iota
	ModeJSON
	ModePlain
)

func DetectMode

func DetectMode(jsonFlag, plainFlag bool) OutputMode

DetectMode returns the output mode from flags and env vars. Priority: explicit flag > env var > default (table).

func (OutputMode) String

func (m OutputMode) String() string

type PaginatedResponse

type PaginatedResponse struct {
	Results    any    `json:"results"`
	HasMore    bool   `json:"has_more"`
	NextCursor string `json:"next_cursor,omitempty"`
}

PaginatedResponse wraps list results with pagination info.

type PlainFormatter

type PlainFormatter struct{}

PlainFormatter outputs TSV (tab-separated values).

func (*PlainFormatter) Format

func (f *PlainFormatter) Format(w io.Writer, data any) error

type TableData

type TableData struct {
	Headers []string
	Rows    [][]string
}

TableData is the canonical input for table rendering.

type TableFormatter

type TableFormatter struct {
	// Fields limits output to these columns. Nil = default columns.
	Fields []string
	// AllFields shows every available column.
	AllFields bool
}

TableFormatter outputs aligned tables using tabwriter.

func (*TableFormatter) Format

func (f *TableFormatter) Format(w io.Writer, data any) error

Jump to

Keyboard shortcuts

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