ui

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 8 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 ui centralizes terminal feedback for the CLI: TTY/color detection, status lines, confirmation prompts, and spinners. Following CLI conventions, human-facing status goes to stderr and is gated on a real terminal; machine output (--json etc.) is the command's own responsibility on stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssumeYes

func AssumeYes() bool

AssumeYes reports whether `--yes` was set (for callers that branch on it).

func ColorEnabled

func ColorEnabled() bool

ColorEnabled reports whether colored output should be produced. It honors `--no-color`, the NO_COLOR convention, TERM=dumb, and non-TTY stdout.

func Confirm

func Confirm(prompt string, def bool) bool

Confirm asks a yes/no question with a safe default. It returns true on `--yes`, the default when `--no-input` or stdin is not a terminal, and otherwise prompts (EOF/blank → default). The prompt and answer flow use stderr/stdin so stdout stays clean for machine output.

func Fail

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

func Info

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

func IsTTY

func IsTTY() bool

IsTTY reports whether stdout is an interactive terminal.

func SetAssumeYes

func SetAssumeYes(v bool)

SetAssumeYes makes Confirm always return true (the `--yes` flag).

func SetNoColor

func SetNoColor(v bool)

SetNoColor disables ANSI color/icons (`--no-color`).

func SetNoInput

func SetNoInput(v bool)

SetNoInput makes Confirm never prompt and return the default (`--no-input`).

func Spin

func Spin(title string, fn func() error) error

Spin runs fn while showing a spinner (on a TTY) or a plain "…" line (otherwise). It returns fn's error; callers report success/failure themselves.

func Success

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

Success/Fail/Warn/Info print a status line to stderr.

func Warn

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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