output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package output renders results for humans or for machines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTTY

func IsTTY(w io.Writer) bool

IsTTY reports whether w is an interactive terminal. Callers use it to decide on colour, padding and progress — never on what the data itself says.

func JSON

func JSON(w io.Writer, v any) error

JSON writes v as indented JSON with a trailing newline.

func Table

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

Table writes rows aligned for a terminal, or tab-separated when piped so that cut/awk see single tabs instead of runs of padding spaces.

func Truncate

func Truncate(s string, n int) string

Truncate shortens s to at most n display columns, marking the cut with an ellipsis. Track and playlist names are long enough to wrap a terminal, which turns a table back into a wall of text.

Types

type Format

type Format string

Format selects the rendering of command results.

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

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates a --format value.

Jump to

Keyboard shortcuts

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