ui

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 11 Imported by: ? 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 renders deploy progress in two modes:

  • Plain: line-by-line transcript, safe for non-tty (CI, pipes, logs).
  • Pretty: Docker-style live block with a spinner and per-step elapsed time, repainted in-place. Only used when stdout is a tty.

Both modes share the Reporter / Step contract so callers stay identical.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reporter

type Reporter interface {
	// Header prints a one-line title at the very top (e.g. service ➜ host).
	Header(format string, args ...any)
	// Step starts a top-level step. The returned handle MUST be terminated
	// with Done() or Fail() before another Step is started.
	Step(name string) Step
	// Info prints a free-form line outside any step (e.g. "Version: 3 → 4").
	Info(format string, args ...any)
	// Warn prints a warning line (non-fatal).
	Warn(format string, args ...any)
	// Close finalises any pending live area. Safe to call multiple times.
	Close()
}

Reporter is the top-level handle a command obtains for the duration of a deploy/restart/rollback. It is concurrency-safe.

func Discard

func Discard() Reporter

Discard returns a reporter that swallows all output. Useful for tests.

func New

func New(w io.Writer) Reporter

New returns the appropriate Reporter for w. If w is a tty, returns a pretty reporter; otherwise a plain one. nil writer falls back to stdout.

func NewPlain

func NewPlain(w io.Writer) Reporter

NewPlain returns a transcript-style reporter that writes one line at a time. Safe for non-tty output. Step elapsed time is printed on Done/Fail.

func NewPretty

func NewPretty(w io.Writer) Reporter

NewPretty returns a Docker-style live reporter. The current step's header line is repainted at ~10Hz to animate the spinner and tick the elapsed timer. Completed steps are frozen as plain transcript above.

type Step

type Step interface {
	// Detail adds an indented info line under this step.
	Detail(format string, args ...any)
	// Quiet freezes the live area and stops the spinner for this step.
	// Use it BEFORE invoking a subprocess that streams its own output to
	// the same terminal (docker build, kubectl rollout, etc) — otherwise
	// the spinner's cursor-up redraw collides with the subprocess lines.
	// After Quiet, Detail/Done/Fail write fresh lines below whatever the
	// subprocess produced. No-op for the plain reporter.
	Quiet()
	// Stream returns a writer that captures subprocess output and renders
	// the last `tail` lines as a scrolling window beneath the step header
	// (Docker-style). ANSI escape sequences are stripped. On Done/Fail
	// the tail window vanishes, leaving only the final ✓/✗ line. For the
	// plain reporter, returns a writer that passes lines through verbatim,
	// indented under the step.
	Stream(tail int) io.Writer
	// Done marks the step completed (✓).
	Done()
	// Fail marks the step failed (✗) with an error.
	Fail(err error)
}

Step is a handle to a single in-progress step. Detail lines accumulate under the step header; on Done()/Fail() the header is frozen with its final state and elapsed time.

Jump to

Keyboard shortcuts

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