output

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package output is the shared rendering engine every command uses. It is TTY-aware (aligned color tables on a terminal, tab-separated values when piped), honors --format=json|yaml|table|text and VIBEXP_FORMAT, applies a built-in gojq filter (--jq), and keeps a strict contract: stdout carries only data, and --format=json is the raw API response body byte-for-byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorEnabled

func ColorEnabled(isTTY bool, getenv func(string) string) bool

ColorEnabled reports whether ANSI color should be emitted: only on a TTY, and never when NO_COLOR is set or TERM=dumb.

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether f is a terminal.

func Render

func Render(w io.Writer, raw []byte, spec *TableSpec, opts Options) error

Render writes raw (the exact API response body) to w per opts. A --jq filter, when present, is applied first and forces JSON output (or YAML if explicitly requested). Table/text formats require a spec; without one they fall back to the raw JSON body, which keeps raw passthrough (e.g. `vibexp api`) correct.

Types

type Column

type Column struct {
	Header string
	Path   string
}

Column is one table/TSV column: a header and a gojq path applied to each row.

type Format

type Format string

Format is an output format selector.

const (
	// FormatAuto picks table on a TTY and TSV when piped.
	FormatAuto  Format = ""
	FormatJSON  Format = "json"
	FormatYAML  Format = "yaml"
	FormatTable Format = "table"
	FormatText  Format = "text"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates a --format / VIBEXP_FORMAT value.

type Options

type Options struct {
	Format Format
	IsTTY  bool
	Color  bool
	JQ     string
}

Options controls a render.

type TableSpec

type TableSpec struct {
	Rows    string
	Columns []Column
}

TableSpec declares how to tabulate a response: Rows is a gojq expression yielding the stream of row values (default "." — the whole document as one row), and Columns extract cells from each row.

Jump to

Keyboard shortcuts

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