output

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderTable

func RenderTable(w io.Writer, headers []string, rows [][]string, colors *Colors) error

RenderTable renders a table with headers and rows using tabwriter

func WriteJSON

func WriteJSON(w io.Writer, v any) error

WriteJSON writes v as indented JSON to w

func WriteKV

func WriteKV(w io.Writer, pairs [][2]string, colors *Colors) error

WriteKV writes key-value pairs aligned in two columns

func WriteTSV

func WriteTSV(w io.Writer, _ []string, rows [][]string) error

WriteTSV writes rows as tab-separated values (no headers per SPEC)

Types

type Colors

type Colors struct {
	// contains filtered or unexported fields
}

Colors provides terminal color styling

func NewColors

func NewColors(noColor bool) *Colors

NewColors creates a Colors instance

func (*Colors) Bold

func (c *Colors) Bold(s string) string

Bold returns text in bold

func (*Colors) Cyan

func (c *Colors) Cyan(s string) string

Cyan returns text in cyan

func (*Colors) Enabled

func (c *Colors) Enabled() bool

Enabled returns true if colors are enabled

func (*Colors) Faint

func (c *Colors) Faint(s string) string

Faint returns text in faint/dim style

func (*Colors) Green

func (c *Colors) Green(s string) string

Green returns text in green

func (*Colors) Red

func (c *Colors) Red(s string) string

Red returns text in red

func (*Colors) StatusColor

func (c *Colors) StatusColor(status string) string

StatusColor returns the appropriate color for a status string

func (*Colors) Yellow

func (c *Colors) Yellow(s string) string

Yellow returns text in yellow

type Formatter

type Formatter struct {
	Writer io.Writer
	Mode   Mode
	Colors *Colors
}

Formatter provides a unified interface for outputting data

func NewFormatter

func NewFormatter(w io.Writer, jsonFlag, plainFlag, noColor bool) *Formatter

NewFormatter creates a formatter with the given settings

func (*Formatter) Output

func (f *Formatter) Output(v any, headers []string, rows [][]string) error

Output writes data in the appropriate format

func (*Formatter) OutputSingle

func (f *Formatter) OutputSingle(v any, kvPairs [][2]string) error

OutputSingle writes a single resource as key-value pairs

type Mode

type Mode int

Mode represents the output format mode

const (
	ModeTable Mode = iota
	ModeJSON
	ModePlain
)

func ModeFromFlags

func ModeFromFlags(jsonFlag, plainFlag bool) Mode

ModeFromFlags returns the output mode based on command flags JSON takes precedence over plain

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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