output

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string

Format specifies how to render output.

const (
	Table Format = "table"
	JSON  Format = "json"
	Plain Format = "plain"
)

func ParseFormat

func ParseFormat(s string) Format

ParseFormat converts a string flag value to a Format.

type Printer

type Printer struct {
	Format Format
	Out    io.Writer
}

Printer handles formatted output.

func (*Printer) PrintJSON

func (p *Printer) PrintJSON(v any) error

PrintJSON writes v as indented JSON.

func (*Printer) PrintPlain

func (p *Printer) PrintPlain(lines []string)

PrintPlain writes each value on its own line.

func (*Printer) PrintTable

func (p *Printer) PrintTable(headers []string, rows [][]string)

PrintTable writes rows as a tab-aligned table. headers are the column names; rows is a slice of slices where each inner slice is one row.

Jump to

Keyboard shortcuts

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