Documentation
¶
Overview ¶
Package terminal contains utilities for terminal interaction.
Index ¶
- type MultiSpinner
- func (m *MultiSpinner) Add(title string)
- func (m *MultiSpinner) Fail(title string)
- func (m *MultiSpinner) Init() tea.Cmd
- func (m *MultiSpinner) Start()
- func (m *MultiSpinner) Stop()
- func (m *MultiSpinner) Success(title string)
- func (m *MultiSpinner) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *MultiSpinner) View() string
- type SpinnerPrinter
- type SuccessSpinner
- func (ss *SuccessSpinner) Fail()
- func (ss *SuccessSpinner) Init() tea.Cmd
- func (ss *SuccessSpinner) Logf(format string, args ...any)
- func (ss *SuccessSpinner) Start()
- func (ss *SuccessSpinner) Success()
- func (ss *SuccessSpinner) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (ss *SuccessSpinner) UpdateText(msg string)
- func (ss *SuccessSpinner) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultiSpinner ¶
type MultiSpinner struct {
// contains filtered or unexported fields
}
MultiSpinner is a collection of independent spinners that get displayed together. Spinners can be dynamically added.
func (*MultiSpinner) Add ¶
func (m *MultiSpinner) Add(title string)
Add adds a spinner to the multi-spinner.
func (*MultiSpinner) Fail ¶
func (m *MultiSpinner) Fail(title string)
Fail marks an existing spinner in the multi-spinner as having failed.
func (*MultiSpinner) Success ¶
func (m *MultiSpinner) Success(title string)
Success marks an existing spinner in the multi-spinner as having succeeded.
type SpinnerPrinter ¶
type SpinnerPrinter interface {
// NewSuccessSpinner returns a new success spinner.
NewSuccessSpinner(msg string) *SuccessSpinner
// WrapWithSuccessSpinner adds spinners around message and run function.
WrapWithSuccessSpinner(msg string, f func() error) error
// WrapAsyncWithSuccessSpinners runs a given function in a separate
// goroutine, consuming events from its event channel and using them to
// display a set of spinners on the terminal. One spinner will be generated
// for each unique event text received. A success/failure indicator will be
// displayed when each event completes.
WrapAsyncWithSuccessSpinners(f func(ch async.EventChannel) error) error
}
SpinnerPrinter prints spinners to the console.
func NewSpinnerPrinter ¶
func NewSpinnerPrinter(out io.Writer, pretty bool) SpinnerPrinter
NewSpinnerPrinter returns a new SpinnerPrinter. If pretty is true, animated spinners will be used; otherwise plain text output will be used.
type SuccessSpinner ¶
type SuccessSpinner struct {
// contains filtered or unexported fields
}
SuccessSpinner is a spinner that can be marked as successful or failed and updates its view accordingly. It is used by MultiSpinner, but can also be used as a standalone spinner.
func (*SuccessSpinner) Fail ¶
func (ss *SuccessSpinner) Fail()
Fail marks the spinner as having failed.
func (*SuccessSpinner) Logf ¶
func (ss *SuccessSpinner) Logf(format string, args ...any)
Logf adds a formatted message to the log printed under the spinner.
func (*SuccessSpinner) Success ¶
func (ss *SuccessSpinner) Success()
Success marks the spinner as having succeeded.
func (*SuccessSpinner) UpdateText ¶
func (ss *SuccessSpinner) UpdateText(msg string)
UpdateText updates the spinner's text.