output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 6 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 formats CLI command results as human-readable tables, machine-readable JSON, or script-friendly tab-separated plain lines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(w io.Writer) bool

IsTerminal reports whether w is backed by an interactive terminal character device.

func WriteJSON

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

WriteJSON encodes v as indented JSON to w.

func WriteRows

func WriteRows(w io.Writer, format Format, jsonData any, headers []string, rows [][]string) error

WriteRows renders tabular data to w according to format. For FormatJSON, jsonData is encoded instead of headers/rows.

Types

type Format

type Format string

Format identifies the CLI output rendering format.

const (
	// FormatTable renders aligned columns using [tabwriter.Writer].
	FormatTable Format = "table"
	// FormatJSON renders pretty-printed JSON to stdout.
	FormatJSON Format = "json"
	// FormatPlain renders headerless tab-separated rows for shell pipelines.
	FormatPlain Format = "plain"
)

func ParseFormat

func ParseFormat(raw string) (Format, error)

ParseFormat validates and normalizes a user-supplied --output flag value.

Jump to

Keyboard shortcuts

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