progress

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package progress renders a Bubble Tea progress bar model — a composable spinner + percentage + label component reused across hex CLIs and TUIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(title string, total int, action Action, opts ...Option) error

Run creates and runs a progress bar program. The action function runs in a goroutine and reports progress via the Sender. The spinner animates independently. The component erases itself on completion.

Types

type Action

type Action func(s *Sender) error

Action is a function that receives a Sender to report progress.

type Bar

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

Bar is a configured progress bar ready to run.

func New

func New(title string, total int) *Bar

New creates a progress bar builder. Call Run to execute it.

func (*Bar) Run

func (b *Bar) Run(action Action) error

Run executes the progress bar with the given action.

func (*Bar) WithOutput

func (b *Bar) WithOutput(height int) *Bar

WithOutput enables a scrolling output window with the given height.

type Failure

type Failure struct {
	Label string
	Err   string
}

Failure records a single item that failed during a progress run.

type Model

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

Model is a bubbletea model that renders a spinner, progress bar, percentage, and current item label. The spinner animates independently from the progress.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type Option

type Option func(*Model)

Option configures a progress bar run.

func WithOutput

func WithOutput(height int) Option

WithOutput enables a scrolling output window below the progress bar with the given number of visible lines. A height of 0 disables the window (default).

type Sender

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

Sender provides methods to report progress from within an Action.

func (*Sender) Err

func (s *Sender) Err() error

Err returns a summary error if any items failed, or nil if all succeeded.

func (*Sender) Failures

func (s *Sender) Failures() []Failure

Failures returns all recorded item failures.

func (*Sender) ItemDone

func (s *Sender) ItemDone(label string)

ItemDone prints a success line for a completed item above the progress bar.

func (*Sender) ItemErr

func (s *Sender) ItemErr(label string, err string)

ItemErr prints an error line for a failed item above the progress bar and records the failure. The error string may contain multiple lines; additional lines are printed indented below the item.

func (*Sender) Output

func (s *Sender) Output(line string)

Output streams a line of command output into the scrolling window below the progress bar. This is a no-op if the output window was not enabled via WithOutput.

func (*Sender) Step

func (s *Sender) Step(index int, label string)

Step updates the progress bar position and current item label.

Jump to

Keyboard shortcuts

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