output

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output provides formatting utilities for CLI output.

Package output provides formatting utilities for CLI output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(data interface{}, opts *Options) error

Print prints data in the specified format

Types

type DefaultFielder

type DefaultFielder interface {
	// DefaultFields returns the list of field names to show by default
	DefaultFields() []string
}

DefaultFielder is an optional interface that models can implement to specify which fields should be shown by default (similar to PHP's @default-fields).

type Format

type Format string

Format represents output format types

const (
	// FormatTable is table format
	FormatTable Format = "table"
	// FormatJSON is JSON format
	FormatJSON Format = "json"
	// FormatYAML is YAML format
	FormatYAML Format = "yaml"
	// FormatCSV is CSV format
	FormatCSV Format = "csv"
	// FormatList is simple list format (one item per line)
	FormatList Format = "list"
)

type Options

type Options struct {
	Format Format
	Fields []string
	Writer io.Writer
}

Options configures output formatting

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns default output options

type SerializedField

type SerializedField struct {
	// Name is the field name as it should appear in CSV headers and table columns
	Name string
	// Value is the field value
	Value interface{}
}

SerializedField represents a single field in serialized output.

type Serializer

type Serializer interface {
	// Serialize returns an ordered list of fields for output.
	// The order of fields in the returned slice determines the column order
	// in CSV and table outputs.
	Serialize() []SerializedField
}

Serializer is an interface that models can implement to control their CSV and table output formatting. This provides PHP Terminus-like behavior where models explicitly define field order and names.

Jump to

Keyboard shortcuts

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