output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package output renders API payloads in user-selected formats (json, yaml, raw, id) with optional --jq filtering. Table rendering is intentionally separate so callers can supply type-specific columns; see RenderTable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, format Format, payload any, opts ...Option) error

Render formats payload and writes it to w. FormatTable is rejected here because table columns depend on the concrete type; use RenderTable instead.

func RenderTable

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

Types

type Format

type Format string
const (
	FormatJSON     Format = "json"
	FormatYAML     Format = "yaml"
	FormatRaw      Format = "raw"
	FormatID       Format = "id"
	FormatTable    Format = "table"
	FormatMarkdown Format = "markdown"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

type Option

type Option func(*Options)

func WithJQ

func WithJQ(expr string) Option

func WithPretty

func WithPretty(p bool) Option

type Options

type Options struct {
	JQ     string
	Pretty bool
}

Jump to

Keyboard shortcuts

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