output

package
v0.6.66 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const FormatFlag = "output format: table, json"

FormatFlag is the standard --output / -o flag description.

Variables

This section is empty.

Functions

func Err

func Err(format string, args ...any)

Err writes to stderr.

Types

type Format

type Format string
const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates and converts a format string.

type Writer

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

Writer wraps an io.Writer with output format control.

func New

func New(format Format) *Writer

func (*Writer) Format

func (w *Writer) Format() Format

func (*Writer) JSON

func (w *Writer) JSON(v any) error

JSON pretty-prints v as JSON.

func (*Writer) Print

func (w *Writer) Print(msg string)

Print writes a plain line.

func (*Writer) Printf

func (w *Writer) Printf(format string, args ...any)

Printf writes a formatted line.

func (*Writer) Table

func (w *Writer) Table(headers []string, rows [][]string)

Table writes rows in a tab-aligned table. headers is the header row.

Jump to

Keyboard shortcuts

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