tui

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Done

func Done()

Done stops the active spinner and prints a success line. When called inside a WithProgress block, it is a no-op.

func Fail

func Fail()

Fail stops the active spinner and prints a failure line. When called inside a WithProgress block, it is a no-op.

func Init

func Init(verbose bool)

Init configures Active for the current run mode. In verbose mode, Active is set to a verboseSpinner that prints messages without animation.

func Pause

func Pause()

Pause stops the spinner animation without printing Done or Fail. Use before handing the terminal to an interactive subprocess; call Resume after it exits.

func PauseWithMessage

func PauseWithMessage()

PauseWithMessage stops the spinner animation and prints a static progress line once. Use this for interactive prompts where the current progress context should stay visible.

func Resume

func Resume()

Resume restarts the spinner animation after a Pause.

func SectionHeader

func SectionHeader(label string) string

SectionHeader returns a fixed-width section label padded with ─ characters. Example: SectionHeader("Kustomize: gitops") → "── Kustomize: gitops ──────────────────────────────────────"

func Start

func Start(message string)

Start begins a new progress spinner with the given message. When called inside a WithProgress block, it is a no-op so the layer message is preserved.

func Update

func Update(message string)

Update changes the suffix on the currently active spinner.

func WithProgress

func WithProgress(message string, fn func() error) error

WithProgress runs fn with a progress spinner showing message. Increments the nesting depth so that any Start/Done/Fail calls inside fn are suppressed — only this layer's Done or Fail line is printed. When already inside a WithProgress block, fn is run directly without spinner management.

Types

type MockSpinner

type MockSpinner struct {
	StartFunc  func(message string)
	UpdateFunc func(message string)
	DoneFunc   func()
	FailFunc   func()
	PauseFunc  func()
	ResumeFunc func()
}

MockSpinner is a mock implementation of the Spinner interface for testing.

func NewMockSpinner

func NewMockSpinner() *MockSpinner

NewMockSpinner creates a new MockSpinner instance.

func (*MockSpinner) Done

func (m *MockSpinner) Done()

Done calls DoneFunc if set, otherwise does nothing.

func (*MockSpinner) Fail

func (m *MockSpinner) Fail()

Fail calls FailFunc if set, otherwise does nothing.

func (*MockSpinner) Pause

func (m *MockSpinner) Pause()

Pause calls PauseFunc if set, otherwise does nothing.

func (*MockSpinner) Resume

func (m *MockSpinner) Resume()

Resume calls ResumeFunc if set, otherwise does nothing.

func (*MockSpinner) Start

func (m *MockSpinner) Start(message string)

Start calls StartFunc if set, otherwise does nothing.

func (*MockSpinner) Update

func (m *MockSpinner) Update(message string)

Update calls UpdateFunc if set, otherwise does nothing.

type Spinner

type Spinner interface {
	Start(message string)
	Update(message string)
	Done()
	Fail()
	Pause()
	Resume()
}

Spinner is the interface for terminal progress feedback.

var Active Spinner = &termSpinner{}

Active is the live Spinner instance used by package-level functions. Replace this in tests or when switching to an alternative UI implementation.

Directories

Path Synopsis
Package plan renders Terraform and Kustomize plan summaries for the CLI.
Package plan renders Terraform and Kustomize plan summaries for the CLI.

Jump to

Keyboard shortcuts

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