output

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(seconds int) string

FormatDuration formats seconds into human-readable duration (e.g., "2m 30s", "1h 15m").

func FormatDurationFloat

func FormatDurationFloat(seconds float64) string

FormatDurationFloat formats float64 seconds into human-readable duration.

func FormatTime

func FormatTime(ts int64) string

FormatTime formats a unix timestamp as local time.

func Truncate

func Truncate(s string, maxLen int) string

Truncate shortens s to maxLen, appending "..." if truncated.

Types

type Column

type Column struct {
	Header   string
	Field    func(item any) string
	MaxWidth int // 0 = no limit
}

Column defines how to extract and display a field.

type JSONPrinter

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

JSONPrinter prints data as pretty-printed JSON.

func (*JSONPrinter) Print

func (p *JSONPrinter) Print(data any, columns []Column) error

type Printer

type Printer interface {
	Print(data any, columns []Column) error
}

Printer formats and outputs data.

func NewPrinter

func NewPrinter(jsonMode bool, noTrunc bool, w io.Writer) Printer

NewPrinter returns a table or JSON printer based on mode flags.

type TablePrinter

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

TablePrinter prints data as aligned tables.

func (*TablePrinter) Print

func (p *TablePrinter) Print(data any, columns []Column) error

Jump to

Keyboard shortcuts

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