output

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package output renders command results as an aligned table or raw JSON, selected by the -o/--output flag. Array responses go through List; a single object goes through Detail as an aligned label/value block.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detail

func Detail[T any](w io.Writer, format Format, v T, fields []Field[T]) error

Detail renders a single object: an aligned "label value" block in table format, or the raw object as indented JSON. As with List, json is deliberately the raw API shape and ignores the field projection. A field whose projected value is empty is omitted from the table (nil/absent API fields don't clutter the view); json still shows it.

func JSON

func JSON(w io.Writer, v any) error

JSON renders a single value as indented JSON — the raw API shape for a single-object response, as List does for arrays.

func List

func List[T any](w io.Writer, format Format, rows []T, cols []Column[T]) error

List renders rows in the given format: an aligned table built from cols, or the raw rows as indented JSON. json is deliberately the raw API shape — the column projection is never applied to it — so cols is ignored for JSON.

func WriteIDs

func WriteIDs(w io.Writer, ids []string) error

WriteIDs prints one identifier per line — the FormatIDs rendering, so `... -o ids | dbosctl workflow cancel -` pipelines work.

Types

type Column

type Column[T any] struct {
	Header string
	Value  func(T) string
}

Column projects one table column from a row of type T.

type Field

type Field[T any] struct {
	Label string
	Value func(T) string
}

Field projects one labeled value from a detail object of type T — Detail's single-object analog of Column.

type Format

type Format string

Format is an -o/--output value.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	// FormatIDs prints one identifier per line, for piping into commands that
	// read IDs from stdin. Only commands with a natural ID honor it (see WriteIDs);
	// others reject it.
	FormatIDs Format = "ids"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates an -o/--output value.

Jump to

Keyboard shortcuts

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