output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package output provides output formatting for CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultJQ

func SetDefaultJQ(query string)

SetDefaultJQ sets a process-wide default jq query.

func SetDefaultTemplate

func SetDefaultTemplate(tmpl string)

SetDefaultTemplate sets a process-wide default template.

Types

type Format

type Format string

Format represents an output format.

const (
	// FormatJSON outputs data as JSON.
	FormatJSON Format = "json"
	// FormatYAML outputs data as YAML.
	FormatYAML Format = "yaml"
	// FormatTable outputs data as an ASCII table.
	FormatTable Format = "table"
)

type Formatter

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

Formatter handles output formatting.

func New

func New(format string) *Formatter

New creates a new formatter with the specified format.

func (*Formatter) Print

func (f *Formatter) Print(data interface{}) error

Print outputs data in the configured format.

func (*Formatter) WithJQ

func (f *Formatter) WithJQ(query string) *Formatter

WithJQ sets a jq-style query to pre-filter data.

func (*Formatter) WithTemplate

func (f *Formatter) WithTemplate(tmpl string) *Formatter

WithTemplate sets a text/template string to render output.

func (*Formatter) WithWriter

func (f *Formatter) WithWriter(w io.Writer) *Formatter

WithWriter sets a custom writer (useful for testing).

Jump to

Keyboard shortcuts

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