format

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 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 Field

type Field[T any] struct {
	Name    string
	Header  string
	Extract func(T) any
}

Field describes one output column and JSON key for type T.

type Printer

type Printer[T any] struct {
	// contains filtered or unexported fields
}

Printer renders a slice of T in the correct output mode.

func New

func New[T any](w io.Writer, isTTY bool, jsonFields, jqExpr string) *Printer[T]

New constructs a Printer.

func (*Printer[T]) AddField

func (p *Printer[T]) AddField(f Field[T])

AddField registers a field.

func (*Printer[T]) AddItem

func (p *Printer[T]) AddItem(item T)

AddItem enqueues one result item.

func (*Printer[T]) Render

func (p *Printer[T]) Render() error

Render writes all items in the appropriate format.

func (*Printer[T]) SetSingleItem

func (p *Printer[T]) SetSingleItem()

SetSingleItem marks the printer to emit a JSON object instead of an array.

Jump to

Keyboard shortcuts

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