printer

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFormat = errors.New("unsupported output format")

Functions

func BufferString

func BufferString(ctx context.Context, streams iostreams.IOStreams, b *spec.UDSBundle) *bytes.Buffer

BufferString returns a human-readable summary of the bundle as a buffer. Packages are displayed in deployment order (topological sort) when the dependency graph can be built. Falls back to declaration order on error.

Types

type Format

type Format string

Format represents an output format.

const (
	FormatText Format = "text"
	FormatJSON Format = "json"
	FormatYAML Format = "yaml"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat converts a string to a Format, returning an error for unknown values.

type JSONPrinter

type JSONPrinter struct{}

JSONPrinter formats result objects as indented JSON.

func (*JSONPrinter) PrintObj

func (p *JSONPrinter) PrintObj(obj any, w io.Writer) error

PrintObj writes an object as indented JSON.

type ResourcePrinter

type ResourcePrinter interface{ PrintObj(any, io.Writer) error }

ResourcePrinter formats a result object.

func NewPrinter

func NewPrinter(format Format) (ResourcePrinter, error)

NewPrinter returns a ResourcePrinter for the given format.

type TextPrinter

type TextPrinter struct{}

TextPrinter formats result objects as human-readable text using reflection and `text` struct tags for field labels.

Supported field types: string, int, bool, float, struct, and slices of these. Unsupported types (map, chan, func, interface) are silently skipped.

func (*TextPrinter) PrintObj

func (p *TextPrinter) PrintObj(obj any, w io.Writer) error

PrintObj writes an object in human-readable text form.

type YAMLPrinter

type YAMLPrinter struct{}

YAMLPrinter formats result objects as YAML.

func (*YAMLPrinter) PrintObj

func (p *YAMLPrinter) PrintObj(obj any, w io.Writer) error

PrintObj writes an object as YAML.

Jump to

Keyboard shortcuts

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