output

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 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 prints what a command has to say: styled with Lip Gloss on a terminal, plain text in a pipe, in CI or for an agent, and JSON when asked, so every command speaks the same way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interactive

func Interactive(in, out *os.File, agent bool) bool

Interactive says whether a person is at the terminal for this command: both input and output are terminals, CI is unset, and no agent is running it. It is the one place every idea and bet command decides between a person at a terminal (pickers, styles, confirms) and a pipe, CI or an agent (plain text or --json, errors instead of questions).

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether a person is at f: it is a character device, and not the null device, which is one too.

func JSON

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

JSON writes v as one indented JSON document and a newline.

Types

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

Printer writes a command's output, styled or plain.

func For

func For(w io.Writer) *Printer

For makes a Printer on w, styled when w is a terminal and NO_COLOR is unset.

func New

func New(w io.Writer, styled bool) *Printer

New makes a Printer on w, styled when styled is true.

func (*Printer) Fields

func (p *Printer) Fields(pairs ...[2]string)

Fields prints one "key value" line per pair, keys padded to one width and dimmed when styled.

func (*Printer) Heading

func (p *Printer) Heading(s string)

Heading prints s, bold when styled.

func (*Printer) Line

func (p *Printer) Line(s string)

Line prints s and a newline.

func (*Printer) Table

func (p *Printer) Table(header []string, rows [][]string)

Table prints header and rows in columns padded to the widest cell, the header bold when styled.

Jump to

Keyboard shortcuts

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