output

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Overview

Package output provides formatters for command output.

Package output provides common output formatting utilities for CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAny added in v0.0.2

func FormatAny(data any, globalFlags *cmdutil.GlobalFlags) error

FormatAny handles the common pattern of formatting any data type for output. This is useful for commands with custom data structures.

func FormatAuthors added in v0.0.2

func FormatAuthors(authors []catalogs.Author, globalFlags *cmdutil.GlobalFlags) error

FormatAuthors handles the common pattern of formatting authors for output.

func FormatModels added in v0.0.2

func FormatModels(models []catalogs.Model, showDetails bool, globalFlags *cmdutil.GlobalFlags) error

FormatModels handles the common pattern of formatting models for output. This encapsulates the switch logic for different output formats.

func FormatProviders added in v0.0.2

func FormatProviders(providers []catalogs.Provider, showKeys bool, globalFlags *cmdutil.GlobalFlags) error

FormatProviders handles the common pattern of formatting providers for output.

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. Deprecated: This type name stutters with package name. TODO: Refactor to use table.Data from internal/cmd/table package.

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