terminal

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package terminal contains utilities for terminal interaction.

Index

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) Init

func (m *MultiSpinner) Init() tea.Cmd

Init satisfies tea.Model.

func (*MultiSpinner) Start

func (m *MultiSpinner) Start()

Start starts the spinners.

func (*MultiSpinner) Stop

func (m *MultiSpinner) Stop()

Stop stops the spinners.

func (*MultiSpinner) Success

func (m *MultiSpinner) Success(title string)

Success marks an existing spinner in the multi-spinner as having succeeded.

func (*MultiSpinner) Update

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

Update satisfies tea.Model.

func (*MultiSpinner) View

func (m *MultiSpinner) View() string

View satisfies tea.Model.

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) Init

func (ss *SuccessSpinner) Init() tea.Cmd

Init satisfies tea.Model.

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) Start

func (ss *SuccessSpinner) Start()

Start starts the spinner.

func (*SuccessSpinner) Success

func (ss *SuccessSpinner) Success()

Success marks the spinner as having succeeded.

func (*SuccessSpinner) Update

func (ss *SuccessSpinner) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update satisfies tea.Model.

func (*SuccessSpinner) UpdateText

func (ss *SuccessSpinner) UpdateText(msg string)

UpdateText updates the spinner's text.

func (*SuccessSpinner) View

func (ss *SuccessSpinner) View() string

View satisfies tea.Model.

Jump to

Keyboard shortcuts

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