format

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

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

Formatter handles formatting and outputting data.

func NewFormatter

func NewFormatter(formatStr string) (*Formatter, error)

NewFormatter creates a new formatter.

func (*Formatter) Print

func (f *Formatter) Print(data interface{}, headers []string, rows [][]string) error

Print formats and prints the data according to the format specification. For table format, headers and rows should be provided. For JSON and template formats, data should be the object to format.

type OutputFormat

type OutputFormat struct {
	Type     string // "table", "json", or "template"
	Template string // template string for custom formats
}

OutputFormat represents the output format type.

func ParseFormat

func ParseFormat(formatStr string) (*OutputFormat, error)

ParseFormat parses the --format flag value. Examples:

  • "" or "table" -> table format with default template
  • "table TEMPLATE" -> table format with custom Go template
  • "json" -> JSON format
  • "TEMPLATE" -> custom Go template

Jump to

Keyboard shortcuts

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