output

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source

Variables

View Source
var (
	Green  = color.New(color.FgGreen).SprintFunc()
	Red    = color.New(color.FgRed).SprintFunc()
	Yellow = color.New(color.FgYellow).SprintFunc()
	Cyan   = color.New(color.FgCyan).SprintFunc()
	Bold   = color.New(color.Bold).SprintFunc()
	Faint  = color.New(color.Faint).SprintFunc()
)

Functions

func AutoSizeColumns added in v0.5.0

func AutoSizeColumns(headers []string, rows [][]string, padding int, flexCols ...int)

AutoSizeColumns truncates flexible columns in-place to fit the terminal width. Fixed columns keep their natural width; the remaining space goes to flex columns.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration in human-readable form

func IsStdinTerminal

func IsStdinTerminal() bool

IsStdinTerminal returns true if stdin is a terminal

func IsTerminal

func IsTerminal() bool

IsTerminal returns true if stdout is a terminal

func PlainStatusIcon

func PlainStatusIcon(status, state string) string

PlainStatusIcon returns a plain text status icon (for --plain output)

func PlainStatusText

func PlainStatusText(status, state string) string

PlainStatusText returns plain status text (for --plain output)

func PrintLogo(w io.Writer)

func RelativeTime

func RelativeTime(t time.Time) string

RelativeTime formats a time as relative to now

func StatusIcon

func StatusIcon(status, state string) string

StatusIcon returns a colored status icon

func StatusText

func StatusText(status, state string) string

StatusText returns colored status text

func TerminalSize

func TerminalSize() (int, int)

TerminalSize returns terminal width and height (defaults: 80x24)

func TerminalWidth

func TerminalWidth() int

TerminalWidth returns the terminal width, or 80 as default

func Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to maxLen display width, adding "..." if truncated Properly handles unicode and wide characters

func WithPager

func WithPager(out io.Writer, fn func(w io.Writer))

WithPager pipes output through less if it exceeds terminal height. The out writer is used as a fallback when paging is not available.

Types

type Printer added in v0.8.1

type Printer struct {
	Out     io.Writer
	ErrOut  io.Writer
	Quiet   bool
	Verbose bool
}

Printer writes formatted output respecting Quiet/Verbose flags.

func DefaultPrinter added in v0.8.1

func DefaultPrinter() *Printer

DefaultPrinter returns a Printer that writes to os.Stdout/os.Stderr.

func (*Printer) Debug added in v0.8.1

func (p *Printer) Debug(format string, args ...any)

func (*Printer) Info added in v0.8.1

func (p *Printer) Info(format string, args ...any)

func (*Printer) Infof added in v0.8.1

func (p *Printer) Infof(format string, args ...any)

func (*Printer) PrintField added in v0.8.1

func (p *Printer) PrintField(label, value string)

func (*Printer) PrintJSON added in v0.8.1

func (p *Printer) PrintJSON(data any) error

func (*Printer) PrintPlainTable added in v0.8.1

func (p *Printer) PrintPlainTable(headers []string, rows [][]string, noHeader bool)

func (*Printer) PrintTable added in v0.8.1

func (p *Printer) PrintTable(headers []string, rows [][]string)

func (*Printer) PrintTree added in v0.8.1

func (p *Printer) PrintTree(root TreeNode)

func (*Printer) PrintViewHeader added in v0.8.1

func (p *Printer) PrintViewHeader(title, webURL string, details func())

func (*Printer) Success added in v0.8.1

func (p *Printer) Success(format string, args ...any)

func (*Printer) Warn added in v0.8.1

func (p *Printer) Warn(format string, args ...any)

type TreeNode added in v0.7.0

type TreeNode struct {
	Label    string
	Children []TreeNode
}

TreeNode represents a node in a displayable tree.

Jump to

Keyboard shortcuts

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