output

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package output provides formatters for command output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string

Format types for output.

const (
	// FormatTable represents table output format.
	FormatTable Format = "table"
	// FormatJSON represents JSON output format.
	FormatJSON Format = "json"
	// FormatYAML represents YAML output format.
	FormatYAML Format = "yaml"
	// FormatWide represents wide table output format.
	FormatWide Format = "wide"
)

func DetectFormat

func DetectFormat(explicitFormat string) Format

DetectFormat auto-detects format based on terminal and environment.

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat converts string to Format with validation.

type Formatter

type Formatter interface {
	Format(w io.Writer, data any) error
}

Formatter interface for all output types.

func NewFormatter

func NewFormatter(format Format) Formatter

NewFormatter creates appropriate formatter based on format.

type FormatterFunc

type FormatterFunc func(io.Writer, any) error

FormatterFunc allows functions to implement Formatter.

func (FormatterFunc) Format

func (f FormatterFunc) Format(w io.Writer, data any) error

Format implements the Formatter interface.

type JSONFormatter

type JSONFormatter struct {
	Indent string
}

JSONFormatter outputs JSON format.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(w io.Writer, data any) error

Format implements the Formatter interface for JSON output.

type TableData

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

TableData represents data formatted for table output.

type TableFormatter

type TableFormatter struct {
	Wide bool
}

TableFormatter outputs table format.

func (*TableFormatter) Format

func (f *TableFormatter) Format(w io.Writer, data any) error

Format outputs data in table format.

type YAMLFormatter

type YAMLFormatter struct{}

YAMLFormatter outputs YAML format.

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(w io.Writer, data any) error

Format outputs data in YAML format.

Jump to

Keyboard shortcuts

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