Documentation
¶
Overview ¶
Package tui provides UI elements for the CLI.
Package tui provides UI elements for the CLI.
Package tui provides UI elements for the CLI.
Package tui provides UI elements for the CLI.
Package tui provides UI elements for the CLI.
Package tui provides UI elements for the CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrUserInterrupted = errors.New("user interrupted")
)
Functions ¶
This section is empty.
Types ¶
type Confirm ¶
type Confirm struct {
// contains filtered or unexported fields
}
Confirm represents a confirm (y/N) input element.
func NewConfirm ¶
NewConfirm creates a new confirm input element. It asks user the question/message and wait for the confirmation (y/N).
func (Confirm) Init ¶
Init initializes the text confirm element. Implements bubbletea.Model interface.
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input represents a text input element.
func NewInput ¶
func NewInput(ctx context.Context, message string, opts ...InputOption) Input
NewInput creates a new text input element.
type InputOption ¶
type InputOption func(m *Input)
InputOption is used to set options when initializing Input. Input can accept a variable number of options.
Example usage:
p := NewInput(ctx, WithValidation(validationFunc), WithHint(hintMessage))
func WithInputDefaultValue ¶
func WithInputDefaultValue(defaultValue string) InputOption
WithInputDefaultValue lets you specify a default value that will be shown in the dialog when the user is prompted for input.
func WithInputHint ¶
func WithInputHint(hint string) InputOption
WithInputHint lets you specify a hint message that will be shown in the dialog when the user is prompted for input.
func WithInputValidation ¶
func WithInputValidation(validateFunc ValidateInputFunc) InputOption
WithInputValidation lets you specify a validate function that will be used to validate user's input.
type InputPassword ¶
type InputPassword struct {
// contains filtered or unexported fields
}
InputPassword represents a password input element.
func NewInputPassword ¶
func NewInputPassword(ctx context.Context, message string, opts ...InputPasswordOption) InputPassword
NewInputPassword creates a new password input element.
func (InputPassword) Init ¶
func (m InputPassword) Init() tea.Cmd
Init initializes the password input element. Implements bubbletea.Model interface.
func (InputPassword) Run ¶
func (m InputPassword) Run() (string, error)
Run runs the password input element.
func (InputPassword) Update ¶
Update updates the password input element. Implements bubbletea.Model interface.
func (InputPassword) View ¶
func (m InputPassword) View() string
View renders the password element view. Implements bubbletea.Model interface.
type InputPasswordOption ¶
type InputPasswordOption func(m *InputPassword)
InputPasswordOption is used to set options when initializing InputPassword. InputPassword can accept a variable number of options.
Example usage:
p := NewInputPassword(ctx, WithValidation(validationFunc), WithHint(hintMessage))
func WithPasswordHint ¶
func WithPasswordHint(hint string) InputPasswordOption
WithPasswordHint lets you specify a hint message that will be shown in the dialog when the user is prompted for input.
func WithPasswordValidation ¶
func WithPasswordValidation(validateFunc ValidateInputFunc) InputPasswordOption
WithPasswordValidation lets you specify a validate function that will be used to validate user's input.
type MultiSelect ¶
type MultiSelect struct { Message string // message to display Choices []MultiSelectOption // possible options user may choose from // contains filtered or unexported fields }
MultiSelect represents a multi-select list.
func NewMultiSelect ¶
func NewMultiSelect(ctx context.Context, message string, choices []MultiSelectOption) MultiSelect
NewMultiSelect creates a new multi-select list.
func (MultiSelect) Init ¶
func (m MultiSelect) Init() tea.Cmd
Init initializes the multi-select list. Implements bubbletea.Model interface.
func (MultiSelect) Run ¶
func (m MultiSelect) Run() ([]MultiSelectOption, error)
Run starts the multi-select list. It returns the selected options and error.
func (MultiSelect) Update ¶
Update updates the multi-select list. Implements bubbletea.Model interface.
func (MultiSelect) View ¶
func (m MultiSelect) View() string
View renders the multi-select list. It returns a string representation of the UI. Implements bubbletea.Model interface.
type MultiSelectOption ¶
MultiSelectOption represents an option in the multi-select list.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents action with spinner element.
func NewSpinner ¶
func NewSpinner(ctx context.Context, l *zap.SugaredLogger, steps []Step, opts ...SpinnerOption) Spinner
NewSpinner creates a new spinner element.
type SpinnerOption ¶
type SpinnerOption func(m *Spinner)
SpinnerOption is used to set options when initializing Spinner. Spinner can accept a variable number of options.
Example usage:
p := NewSpinner(ctx, WithPretty(bool))
func WithSpinnerPrettyPrint ¶
func WithSpinnerPrettyPrint(prettyPrint bool) SpinnerOption
WithSpinnerPrettyPrint lets you specify pretty print for the spinner. It will print the spinner in a pretty way. In case the spinner is not pretty, it will print the spinner in a verbose way.
type Step ¶
type Step struct { // Desc is a human-readable description of the step. Desc string // F is the function that will be called to execute the step. F func(ctx context.Context) error }
Step provides a way to run a function with a pretty loading spinner animation.
type ValidateInputFunc ¶
ValidateInputFunc is a function that returns an error if the input is invalid.