output

package
v2.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package output provides formatted terminal output utilities for the CLI.

This package offers consistent styling for success messages, errors, warnings, informational text, headers, key-value pairs, and tables. All output includes appropriate color coding for better readability in terminal environments.

Example Usage

output.Success("Operation completed")
output.Warning("Something looks off: %v", err)
output.KeyValue("Status", "Running")
output.Table([]string{"ID", "Name"}, rows)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes added in v2.6.0

func Bytes(value int64) string

Bytes renders a signed byte count in human-readable form.

func Configure added in v2.15.0

func Configure(stdout, stderr io.Writer, jsonMode, noColor bool, label string)

Configure binds output to the current command's writers and output mode.

func Confirm added in v2.15.0

func Confirm(ctx context.Context, input io.Reader, out io.Writer, label string) (bool, error)

Confirm uses a terminal selector, falling back to line input for scripts.

func CoordinatedWriter added in v2.15.0

func CoordinatedWriter(w io.Writer) io.Writer

CoordinatedWriter clears loading while another writer uses the terminal.

func Copy added in v2.15.0

func Copy(ctx context.Context, dst io.Writer, src io.Reader, total int64, label string, enabled bool) (int64, error)

Copy copies a transfer while reporting bytes, or activity for unknown totals.

func Header(format string, a ...any)

Header prints a purple section heading. Use this to introduce sections of output. The message is prefixed with a newline for visual separation.

func Info

func Info(format string, a ...any)

Info prints an info message in purple. The message is prefixed with a newline for visual separation. Format specifiers and arguments work like fmt.Printf.

func IsTerminal added in v2.15.0

func IsTerminal(value any) bool

IsTerminal checks the actual writer, including terminal capability.

func KeyValue

func KeyValue(key string, value any)

KeyValue prints a key-value pair with the muted aligned labels and neutral values. This is useful for displaying structured information like image details or configuration values.

func ReadWithContext added in v2.15.0

func ReadWithContext[T any](ctx context.Context, input io.Reader, read func(io.Reader) (T, error)) (T, error)

ReadWithContext reads input until read returns or ctx is canceled. Pipes, sockets and terminals are interrupted in place; regular files never block; other readers fall back to readAsyncInternal.

func Secret added in v2.15.0

func Secret(ctx context.Context, input io.Reader, out io.Writer, label, flagName string) (string, error)

Secret reads a masked value from a terminal, or one line from piped input. An empty value asks the caller to pass flagName instead.

func Showing

func Showing(shown int, total int64, label string)

Showing prints a pagination summary in the form "Showing: shown/total label".

func StartLoading added in v2.15.0

func StartLoading(ctx context.Context) *tracker

StartLoading tracks the current command while a request is in progress.

func StartTracker added in v2.15.0

func StartTracker(ctx context.Context, out io.Writer, enabled bool, labels ...string) *tracker

StartTracker renders a checklist only for interactive text output.

func Stderr added in v2.15.0

func Stderr() io.Writer

Stderr returns the current command's diagnostic writer.

func Stdout added in v2.15.0

func Stdout() io.Writer

Stdout returns the current command's result writer.

func Success

func Success(format string, a ...any)

Success prints a success message in green. The message is prefixed with a newline for visual separation. Format specifiers and arguments work like fmt.Printf.

func SuspendProgress added in v2.15.0

func SuspendProgress() func()

SuspendProgress pauses every active tracker until the returned function runs.

func Table

func Table(headers []string, rows [][]string) error

Table prints a formatted table with headers and rows. Rendering uses Lip Gloss table styles with zebra-striped rows.

func TintEnabled

func TintEnabled(value string) string

TintEnabled applies tints for enabled/disabled values.

func TintInsecure

func TintInsecure(value string) string

TintInsecure applies warning tints for insecure values.

func TintStatus

func TintStatus(value string) string

TintStatus applies semantic status coloring to a value.

func TintYesNo

func TintYesNo(value string) string

TintYesNo applies tints for yes/no style values.

func UnsignedBytes added in v2.6.0

func UnsignedBytes(value uint64) string

UnsignedBytes renders an unsigned byte count in human-readable form.

func Warning

func Warning(format string, a ...any)

Warning prints a warning message in yellow. The message is prefixed with a newline for visual separation. Format specifiers and arguments work like fmt.Printf.

func WriteError added in v2.15.0

func WriteError(w io.Writer, err error)

WriteError renders the command error once through Fang's error handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

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