output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package output provides gh-style pretty printing: tables, key-value, JSON, and status messages.

Index

Constants

This section is empty.

Variables

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

Functions

func Bold

func Bold(msg string)

func Dim

func Dim(msg string)

func Error

func Error(msg string)

func FormatCell

func FormatCell(v any) string

func FormatRelativeTime

func FormatRelativeTime(s string) string

func Info

func Info(msg string)

func IsJSON

func IsJSON() bool

func IsTTY

func IsTTY() bool

func JSON

func JSON(data any)

func KV

func KV(pairs []KVPair)

func KVWithTitle

func KVWithTitle(pairs []KVPair, title string)

func OutputDetail

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

func OutputList

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

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 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
}

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