output

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, format Format, data any) error

Fprint formats and writes data to w in the given format.

func Print

func Print(format Format, data any) error

Print formats and writes data to stdout in the given format.

func PrintData

func PrintData(cmd *cobra.Command, columns []Column, rows [][]string, data any) error

PrintData is the unified output function for list commands. For table format, it prints columns and rows as an aligned table. For JSON/YAML, it serializes the structured data.

func PrintTable

func PrintTable(w io.Writer, columns []Column, rows [][]string)

PrintTable writes rows as an aligned table.

Types

type Column

type Column struct {
	Header string
	Width  int // 0 = auto
}

Column defines a table column.

type Format

type Format string

Format represents an output format.

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

func FormatFromCmd

func FormatFromCmd(cmd *cobra.Command) Format

FormatFromCmd reads the --output flag value from a cobra command.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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