output

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: GPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package output renders command results as a human readable table or as machine readable JSON/YAML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Formats

func Formats() []string

Formats lists every valid --output value, for help text and validation.

func Write

func Write(w io.Writer, f Format, v any, table Table) error

Write emits v in the requested format. For FormatTable the caller supplies a pre-built table, since the flat grid rarely maps 1:1 onto the data shape.

func WriteTable

func WriteTable(w io.Writer, t Table) error

WriteTable renders the table with tab-aligned columns.

Types

type Format

type Format string

Format is an output encoding selected by the global -o/--output flag.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatYAML  Format = "yaml"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates a user supplied format string.

func (Format) Structured

func (f Format) Structured() bool

Structured reports whether the format is machine readable, which callers use to suppress decorative output.

type Table

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

Table is a simple column-aligned grid.

func (*Table) AddRow

func (t *Table) AddRow(cells ...any)

AddRow appends a row, converting each cell with fmt.Sprint.

Jump to

Keyboard shortcuts

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