Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecWithSpinner ¶
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
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 (*Spinner) Error ¶ added in v1.203.0
Error stops the spinner and displays an error message with xmark. Error is idempotent and safe to call multiple times.
func (*Spinner) Println ¶
Println prints a line above the live spinner line, permanently, without interrupting the spinner. In non-interactive output it's just ui.Writeln.
func (*Spinner) SetInterruptHandler ¶
func (s *Spinner) SetInterruptHandler(handler func())
SetInterruptHandler registers a function that is called when the user presses ctrl+c while the spinner is showing. The terminal is in raw mode then, so the keypress never becomes a signal; without a handler the spinner would disappear while the work continues. Set it before Start. The handler runs on the spinner's goroutine.
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.