output

package
v1.1.1-0...-c617925 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output centralises how commands render results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detail

func Detail(w io.Writer, fields []Field) error

Detail writes an aligned key/value view of a single resource. Labels are coloured and, when present, sources dimmed — both after alignment.

func Render

func Render(w io.Writer, data any, opts Options, human func(io.Writer) error) error

Render writes data as JSON (applying JQ) when JSON output is requested, otherwise delegates to human. human may be nil when only JSON is expected.

func Success

func Success(w io.Writer, format string, a ...any)

Success writes a ✓-prefixed confirmation line.

func Table

func Table(w io.Writer, headers []string, rows [][]string) error

Table writes a borderless, aligned table, bolding the header after alignment.

Types

type Field

type Field struct {
	Label  string
	Value  string
	Source string
}

Field is one row in a detail view: a label, a value, and an optional source (e.g. where a config value came from). When any field has a source, Detail renders a third, dimmed column.

type Options

type Options struct {
	JSON bool   // emit JSON instead of a human view
	JQ   string // filter JSON through this jq expression (implies JSON)
}

Options selects the output format for a single command invocation.

Jump to

Keyboard shortcuts

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