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 ¶
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.
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.