output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package output renders LinkedIn API JSON in table/json/yaml/csv/id. One renderer serves every command, driven by JSON normalization: an object becomes one row, an array of objects becomes many, nested fields flatten to dotted keys. Output is deterministic (preferred-key order then alphabetical) and pipe-clean (notes go to stderr) per the cliwright standard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(data json.RawMessage, opts Options) error

Render writes data in the requested format. data is the raw API response JSON.

func SanitizeTerminal

func SanitizeTerminal(s string) string

SanitizeTerminal strips ANSI escape sequences and control characters from text that originated in the API (contact names, error bodies, labels) before it is printed to a human terminal. Without this, a crafted value like a contact named "\x1b]0;pwned\a" could rewrite the terminal title, move the cursor, or inject color — a real terminal-escape injection. Machine formats (json/yaml/csv) are left faithful; only the human table view and error output pass through here. Ported from the fleet-standard SanitizeText, which handles this and linkedin reuses verbatim.

Types

type Format

type Format string

Format is an output format.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatYAML  Format = "yaml"
	FormatCSV   Format = "csv"
	FormatID    Format = "id"
)

func (Format) Valid

func (f Format) Valid() bool

Valid reports whether f is a known format.

type Options

type Options struct {
	Format  Format
	Columns []string // explicit column selection (overrides the preferred order)
	NoColor bool
	Quiet   bool
	JQ      string // optional gojq expression applied before rendering
	MaxCols int    // cap auto-detected columns (default 10)
	Out     io.Writer
	Err     io.Writer
}

Options configure a single Render call.

Jump to

Keyboard shortcuts

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