clioutput

package
v0.1.0-rc.49 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: BSD-3-Clause Imports: 9 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 clioutput renders plain, copyable CLI results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandOf

func CommandOf(err error) (string, bool)

CommandOf returns the nearest attached command context from a non-nil wrapper.

func CommandTitle

func CommandTitle(program, path string) string

CommandTitle returns a canonical command title without argument placeholders.

func Render

func Render(message Message) (string, error)

Render returns newline-terminated plain text.

func StartProgress

func StartProgress(ctx context.Context, stdout, stderr io.Writer, human bool, label string) func()

StartProgress shows a delayed loader during a quiet human wait. Call the returned stop function before writing anything to either stream or returning. It joins the renderer and clears its line, even on cancellation.

func TerminalWidth

func TerminalWidth(output io.Writer, fallback int) int

TerminalWidth uses the destination's terminal size, or fallback for pipes and files.

func WithoutProgress

func WithoutProgress(ctx context.Context) context.Context

WithoutProgress disables progress rendering for the invocation.

func WrapCommand

func WrapCommand(command string, err error) error

WrapCommand attaches command context to err.

func Write

func Write(output io.Writer, message Message) error

Write emits one newline-terminated result.

Types

type Block

type Block interface {
	// contains filtered or unexported methods
}

Block is content rendered inside a message.

func Fields

func Fields(values ...Field) Block

Fields renders aligned label-value pairs.

func Line

func Line(value string) Block

Line prints one logical row. only the terminal may wrap it.

func Literal

func Literal(value string) Block

Literal prints one copyable value on its own line.

func Section

func Section(title string, blocks ...Block) Block

Section places a title above its content.

func Table

func Table(head []string, rows [][]string, empty string) Block

Table aligns comparable records without splitting their values.

func Text

func Text(value string) Block

Text renders wrapped prose.

type Field

type Field struct {
	Label string
	Value string
	// prose may wrap at spaces. other values are printed intact.
	Prose bool
}

Field is one label and value in an aligned field list.

type Message

type Message struct {
	Blocks []Block
}

Message holds the lines of one result or diagnostic.

Jump to

Keyboard shortcuts

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