output

package
v0.0.0-...-1096d29 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package output renders command results in the format selected by --output:

  • table (default, human-friendly aligned columns)
  • json (pretty-printed for piping into jq)
  • yaml (pretty-printed YAML)

`Render` is the single entry point used by the operation runner. For a JSON array of objects it produces a table whose columns are the union of top-level keys across rows. For non-tabular shapes it falls back to JSON so the user always sees the full payload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, format Format, body []byte) error

Render writes body to w in the requested format. body is the raw response bytes from the upstream API; the function decodes once and dispatches.

func RenderTable

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

RenderTable writes an aligned table. Each row has len == len(headers); short rows are padded with empty cells, long rows are truncated to header width.

Types

type Format

type Format string

Format names the three supported output modes.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatYAML  Format = "yaml"
)

Possible Format values.

func Parse

func Parse(raw string) (Format, error)

Parse normalises a user-supplied --output value. An empty string maps to FormatTable.

Jump to

Keyboard shortcuts

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