output

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 9 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 instant) string

FormatTime formats an instant as local wall-clock time, or "-" when unset.

func Truncate

func Truncate(s string, maxLen int) string

Truncate shortens s to maxLen display columns, 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 Format added in v1.3.1

type Format int

Format selects how command output is serialized.

const (
	// FormatTable renders human-readable aligned columns (the default).
	FormatTable Format = iota
	// FormatJSON renders pretty-printed JSON.
	FormatJSON
	// FormatTOON renders Token-Oriented Object Notation — a compact
	// serialization that drops the per-row repeated keys JSON emits for
	// uniform arrays, materially reducing token count for list output.
	FormatTOON
)

func (Format) Structured added in v1.3.1

func (f Format) Structured() bool

Structured reports whether the format is a machine-readable dump (JSON or TOON) rather than the human table view. Table footers, detail views, and interactive prompts are suppressed when the output is structured.

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(format Format, noTrunc bool, w io.Writer) Printer

NewPrinter returns the printer for the requested output format. noTrunc only affects the table printer; structured formats (JSON/TOON) never truncate.

type TOONPrinter added in v1.3.1

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

TOONPrinter prints data as TOON (Token-Oriented Object Notation). It routes through toon.Marshal directly — the same encoder the Flashduty SDKs and MCP server use, so the on-the-wire encoding stays identical across tools.

func (*TOONPrinter) Print added in v1.3.1

func (p *TOONPrinter) Print(data any, _ []Column) error

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