ui

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 3 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorMode

type ColorMode int

ColorMode controls whether CLI output should use terminal colors.

const (
	// ColorAuto enables color only when output is connected to a TTY.
	ColorAuto ColorMode = iota
	// ColorAlways always enables color.
	ColorAlways
	// ColorNever always disables color.
	ColorNever
)

func ParseColorMode

func ParseColorMode(value string) (ColorMode, error)

ParseColorMode parses a user-provided color mode.

type UI

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

UI owns CLI output streams and color capability for rendering user-facing output.

func New

func New(stdout, stderr io.Writer, mode ColorMode, isTTY bool) *UI

New creates a UI with resolved color support.

func (*UI) Color

func (u *UI) Color() bool

Color reports whether color output is enabled.

func (*UI) Errf

func (u *UI) Errf(format string, a ...any)

Errf writes formatted output to stderr.

func (*UI) Errln

func (u *UI) Errln(args ...any)

Errln writes a line to stderr.

func (*UI) Outf

func (u *UI) Outf(format string, a ...any)

Outf writes formatted output to stdout.

func (*UI) Stderr

func (u *UI) Stderr() io.Writer

Stderr returns the configured standard error writer.

func (*UI) Stdout

func (u *UI) Stdout() io.Writer

Stdout returns the configured standard output writer.

Jump to

Keyboard shortcuts

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