output

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package output provides gh-style pretty printing: tables, key-value, JSON, status messages, and script-friendly output (--jq).

Index

Constants

This section is empty.

Variables

View Source
var Current = &Opts{Format: "table"}

Functions

func ApplyJQ added in v0.2.0

func ApplyJQ(data any, expr string) error

ApplyJQ applies a jq expression to data and prints results to stdout. Returns an error if the expression is invalid.

func Bold

func Bold(msg string)

func Dim

func Dim(msg string)

func Error

func Error(msg string)

func Errorf added in v0.2.0

func Errorf(format string, a ...any)

Errorf prints a red ✗ error to stderr.

func FormatCell

func FormatCell(v any) string

func FormatCellPlain added in v0.2.0

func FormatCellPlain(v any) string

FormatCellPlain formats a cell value without ANSI colors or timestamp rewriting. It is intended for TUI rendering where colors are applied later and timestamps should display as-is.

func FormatRelativeTime

func FormatRelativeTime(s string) string

func Hint added in v0.2.0

func Hint(msg string)

Hint prints a dim hint to stderr.

func Hyperlink(text, target string) string

func Info

func Info(msg string)

func IsJSON

func IsJSON() bool

func IsTTY

func IsTTY() bool

func JSON

func JSON(data any) error

func KV

func KV(pairs []KVPair)

func KVWithTitle

func KVWithTitle(pairs []KVPair, title string)

func OutputDetail

func OutputDetail(raw any, fields []FieldDef, title string) error

func OutputList

func OutputList(raw any, rows []map[string]any, cols []Column, total, page int) error

func Panel added in v0.2.0

func Panel(title string, lines ...string)

func Resolve

func Resolve(m map[string]any, key string) any

func Success

func Success(msg string)

func Table

func Table(rows []map[string]any, cols []Column)

func TableTo

func TableTo(w io.Writer, rows []map[string]any, cols []Column, emptyMsg string)

func VerboseF added in v0.2.0

func VerboseF(format string, a ...any)

VerboseF prints debug info to stderr when --verbose is set.

func Warning

func Warning(msg string)

func Writer

func Writer() io.Writer

Types

type Column

type Column struct {
	Header string
	Key    string
}

Column describes a table column with a display header and a key path (dot-separated for nested access, e.g. "course.namePrimary").

type FieldDef

type FieldDef struct {
	Key       string
	Label     string
	SkipEmpty bool
}

type KVPair

type KVPair struct {
	Key       string
	Value     any
	SkipEmpty bool
}

type Opts

type Opts struct {
	Format  string // "table" or "json"
	NoColor bool
	JQ      string // jq filter expression (implies JSON)
	Verbose bool
}

Opts holds output formatting preferences set from root flags.

Jump to

Keyboard shortcuts

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