output

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package output provides colored terminal output functions.

Log-level functions (Status, Info, Debug, Verbose, DryRun, Warning, Error) delegate to the logging package for dual-write (terminal + file) support. Value styling functions (Name, Path, etc.) and raw Print/Println remain here.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Output writers (safe to replace concurrently for tests)
	Stdout io.Writer = newAtomicWriter(os.Stdout)
	Stderr io.Writer = newAtomicWriter(os.Stderr)
)

Functions

func Bool added in v0.6.0

func Bool(value bool) string

Bool styles a boolean value (green for true, red for false)

func Command added in v0.6.0

func Command(value string) string

Command styles a command example (cyan + faint)

func Debug added in v0.6.0

func Debug(format string, args ...interface{})

Debug prints a debug message with a faint [D] prefix.

func DisableColors

func DisableColors()

DisableColors disables colored output for both value styling and logging prefixes.

func DryRun added in v0.6.0

func DryRun(format string, args ...interface{})

DryRun prints what would be executed with a cyan [dry-run] prefix. Stops the global status line first so the bubbletea inline renderer does not corrupt the log output on stdout.

func EnableColors

func EnableColors()

EnableColors enables colored output for both value styling and logging prefixes.

func Error

func Error(format string, args ...interface{})

Error prints an error message with a red [x] prefix. Stops the global status line first so the bubbletea inline renderer does not corrupt the log output on stderr.

func Header(value string) string

Header styles a section header (bold)

func Info

func Info(format string, args ...interface{})

Info prints an info message with a blue [i] prefix.

func IsDebug added in v0.6.0

func IsDebug() bool

IsDebug returns true if debug output is enabled

func IsDefaultMode added in v0.7.0

func IsDefaultMode() bool

IsDefaultMode returns true when the terminal log level is DefaultLevel.

func IsQuiet added in v0.6.0

func IsQuiet() bool

IsQuiet returns true if quiet mode is active (--quiet)

func IsVerbose added in v0.6.0

func IsVerbose() bool

IsVerbose returns true if at least verbose output is enabled (-v, -vv, or --debug)

func IsVeryVerbose added in v0.7.0

func IsVeryVerbose() bool

IsVeryVerbose returns true if very verbose output is enabled (-vv or --debug)

func Name added in v0.6.0

func Name(value string) string

Name styles a container name, hostname, or similar identifier (cyan)

func Number added in v0.6.0

func Number(value string) string

Number styles a numeric value like memory, CPUs, or ports (magenta)

func Package added in v0.6.0

func Package(value string) string

Package styles a package name (cyan)

func Path added in v0.6.0

func Path(value string) string

Path styles a file path (blue)

func Print

func Print(format string, args ...interface{})

Print prints a plain message to stdout. Suppressed in quiet mode.

func Println

func Println(args ...interface{})

Println prints a plain message to stdout with a newline. Suppressed in quiet mode.

func ReplaceStderr

func ReplaceStderr(w io.Writer) func()

ReplaceStderr sets the package stderr to w and returns a restore func.

func ReplaceStdout

func ReplaceStdout(w io.Writer) func()

ReplaceStdout sets the package stdout to w and returns a restore func. This is safe to use in tests concurrently.

func Result added in v0.8.0

func Result(format string, args ...interface{})

Result prints a message with a green [*] prefix. Unlike Status, it always renders on the terminal in default mode and does not route through the animated status line. Use for final command output rather than transient progress updates. Suppressed in quiet mode.

func Status

func Status(format string, args ...interface{})

Status prints a status message with a green [*] prefix. In default mode on a TTY, it routes through the global status line.

func StopGlobalStatusLine added in v0.7.0

func StopGlobalStatusLine()

StopGlobalStatusLine is the exported entry point for stopping the status line from main.go and container.go.

func Verbose added in v0.6.0

func Verbose(format string, args ...interface{})

Verbose prints a verbose message with a faint [.] prefix.

func Warning

func Warning(format string, args ...interface{})

Warning prints a warning message with a yellow [!] prefix. Stops the global status line first so the bubbletea inline renderer does not corrupt the log output on stderr.

Types

type Spinner added in v0.6.0

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

Spinner wraps a bubbletea program with a bubbles/spinner component.

func NewSpinner added in v0.6.0

func NewSpinner(message string) *Spinner

NewSpinner creates a spinner with a status message.

func StartSpinner added in v0.6.0

func StartSpinner(message string) *Spinner

StartSpinner is a convenience that creates and starts a spinner. In default mode on a TTY, delegates to the global status line. In default mode without a TTY, returns a silent (no-op) spinner.

func (*Spinner) Start added in v0.6.0

func (s *Spinner) Start()

Start begins the spinner animation in a background goroutine. Degrades gracefully:

  • Quiet mode: suppressed entirely
  • Default mode, non-TTY: silent (no output)
  • Verbose/debug mode, non-TTY: prints static "[*] message\n" (no animation)
  • TTY + NO_COLOR: animated spinner without ANSI colors
  • TTY: animated Braille dot spinner via bubbletea inline rendering

func (*Spinner) Stop added in v0.6.0

func (s *Spinner) Stop()

Stop halts the spinner and clears its line. Must be called before printing any follow-up status messages.

func (*Spinner) UpdateMessage added in v0.6.0

func (s *Spinner) UpdateMessage(msg string)

UpdateMessage changes the spinner text while running. Used for multi-phase operations (e.g., kernel install -> retry build).

Jump to

Keyboard shortcuts

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