Documentation
¶
Index ¶
- Variables
- func Print(w *os.File, v interface{}) error
- func PrintJSON(w *os.File, v interface{}) error
- func PrintList[T any](w *os.File, items []T, hasMore bool, hint string) error
- func PrintListFull[T any](w *os.File, items []T, hasMore bool, hint string, truncatedFields []string) error
- func PrintObject(w *os.File, obj interface{}) error
- func PrintObjectFull(w *os.File, obj, context interface{}, truncatedFields []string) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.