output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Format = "json"

Format selects the output encoding for Print: "json" (default) or the experimental "toon". Set once from the --output flag before any command runs.

Functions

func Print

func Print(w *os.File, v interface{}) error

Print encodes v to w in the selected Format. JSON is indented on a TTY and compact when piped; TOON is always line-oriented.

func PrintJSON

func PrintJSON(w *os.File, v interface{}) error

PrintJSON encodes v as JSON regardless of the global Format — indented on a TTY, compact when piped. Used by the raw `dharma api` passthrough, which must stay JSON (and jq-parseable) even under --output toon.

func PrintList

func PrintList[T any](w *os.File, items []T, hasMore bool, hint string) error

PrintList wraps a slice in the list envelope:

{"ok":true,"count":N,"has_more":bool,"hint":"...","data":[...]}

count is derived from the slice length; hint is omitted when empty. A nil slice is normalized to [] so data is never JSON null.

func PrintListFull

func PrintListFull[T any](w *os.File, items []T, hasMore bool, hint string, truncatedFields []string) error

PrintListFull is PrintList plus truncatedFields — names of fields shortened in one or more items (omitted when nil), so a consumer can detect truncation without scanning the in-string markers.

func PrintObject

func PrintObject(w *os.File, obj interface{}) error

PrintObject wraps a single value in the object envelope: {"ok":true,"data":{...}}. It is PrintObjectFull with no context/truncated_fields — both omitempty, so the JSON is byte-identical to a bare {ok,data} envelope.

func PrintObjectFull

func PrintObjectFull(w *os.File, obj, context interface{}, truncatedFields []string) error

PrintObjectFull is PrintObject plus an optional sibling `context` block (pre-computed hints that save a round trip) and `truncated_fields` (names of fields shortened in data). Both are omitted when nil/empty, degrading to a plain object envelope.

Types

This section is empty.

Jump to

Keyboard shortcuts

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