spinner

package
v1.203.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecWithSpinner

func ExecWithSpinner(progressMsg, completedMsg string, operation func() error) error

ExecWithSpinner runs an operation with a spinner UI. ProgressMsg is shown while operation is running (e.g., "Starting container"). CompletedMsg is shown when operation completes successfully (e.g., "Started container").

func ExecWithSpinnerDynamic added in v1.203.0

func ExecWithSpinnerDynamic(progressMsg string, operation func() (string, error)) error

ExecWithSpinnerDynamic runs an operation with a spinner UI where the completion message is determined dynamically by the operation. The operation returns both the completion message and any error. This is useful when the completion message depends on the result of the operation (e.g., displaying refs that were compared).

Types

type Spinner added in v1.203.0

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

Spinner provides a start/stop API for long-running operations where multiple sequential steps need to run while the spinner is displayed. For single operations, prefer ExecWithSpinner or ExecWithSpinnerDynamic instead.

Example usage:

s := spinner.New("Processing...")
s.Start()
defer s.Stop()

// Do multiple operations while spinner runs...
step1()
step2()

s.Success("Processing complete")

func New added in v1.203.0

func New(progressMsg string) *Spinner

New creates a new Spinner with the given progress message.

func (*Spinner) Error added in v1.203.0

func (s *Spinner) Error(message string)

Error stops the spinner and displays an error message with xmark. Error is idempotent and safe to call multiple times.

func (*Spinner) Start added in v1.203.0

func (s *Spinner) Start()

Start begins displaying the spinner. Call Stop() when done.

func (*Spinner) Stop added in v1.203.0

func (s *Spinner) Stop()

Stop stops the spinner without displaying a completion message. Use Success() or Error() instead to show a completion status. Stop is idempotent and safe to call multiple times.

func (*Spinner) Success added in v1.203.0

func (s *Spinner) Success(message string)

Success stops the spinner and displays a success message with checkmark. Success is idempotent and safe to call multiple times.

Jump to

Keyboard shortcuts

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