Documentation
¶
Index ¶
- Variables
- func Confirm(prompt string, opts ...ConfirmOptions) (tui.Result[bool], error)
- func Input(prompt string, opts ...InputOptions) (tui.Result[string], error)
- func MultiSelect[T any](prompt string, items []MultiSelectItem[T], opts ...MultiSelectOptions) (tui.Result[[]T], error)
- func RunWizard[T any](title string, initialState T, steps []Step[T]) (T, error)
- func Select[T any](prompt string, items []SelectItem[T], opts ...SelectOptions) (tui.Result[T], error)
- func WithProgress[T any](message string, fn func() (T, error)) (T, error)
- type ConfirmModel
- type ConfirmOptions
- type InputModel
- type InputOptions
- type MultiSelectItem
- type MultiSelectModel
- type MultiSelectOptions
- type ProgressModel
- type SelectItem
- type SelectModel
- type SelectOptions
- type Step
- type StepResult
- type Wizard
- type WizardOption
Constants ¶
This section is empty.
Variables ¶
var (
ErrRequired = errors.New("this field is required")
)
Validation errors
Functions ¶
func MultiSelect ¶
func MultiSelect[T any](prompt string, items []MultiSelectItem[T], opts ...MultiSelectOptions) (tui.Result[[]T], error)
MultiSelect displays a multi-select list and returns the selected items
func Select ¶
func Select[T any](prompt string, items []SelectItem[T], opts ...SelectOptions) (tui.Result[T], error)
Select displays a selection list and returns the selected item's value
Types ¶
type ConfirmModel ¶
type ConfirmModel struct {
// Result
Result tui.Result[bool]
// contains filtered or unexported fields
}
ConfirmModel is the bubbletea model for confirmation
type ConfirmOptions ¶
type ConfirmOptions struct {
DefaultYes bool // Default to Yes (default: true)
CanGoBack bool // Allow back navigation
Description string // Optional description text
}
ConfirmOptions for confirmation dialog
type InputModel ¶
type InputModel struct {
// Result
Result tui.Result[string]
// contains filtered or unexported fields
}
InputModel is the bubbletea model for text input
type InputOptions ¶
type InputOptions struct {
Placeholder string // Placeholder text
Required bool // Whether input is required
Mask bool // Mask input (for passwords)
Initial string // Initial value
Validate func(string) error // Validation function
CharLimit int // Character limit (0 = unlimited)
ShowHelp bool // Show help footer
CanGoBack bool // Allow back navigation
}
InputOptions for text input customization
type MultiSelectItem ¶
MultiSelectItem represents an item in a multi-select list
type MultiSelectModel ¶
type MultiSelectModel[T any] struct { // Result Result tui.Result[[]T] // contains filtered or unexported fields }
MultiSelectModel is the bubbletea model for multi-selection
func (*MultiSelectModel[T]) Init ¶
func (m *MultiSelectModel[T]) Init() tea.Cmd
Init implements tea.Model
func (*MultiSelectModel[T]) View ¶
func (m *MultiSelectModel[T]) View() string
View implements tea.Model
type MultiSelectOptions ¶
type MultiSelectOptions struct {
Initial map[any]bool // Initial selection state (by Value)
PageSize int // Number of items to show (default: 8)
CanGoBack bool // Allow back navigation (default: true)
}
MultiSelectOptions for customization
type ProgressModel ¶
type ProgressModel[T any] struct { // contains filtered or unexported fields }
ProgressModel shows a spinner while running an async operation
type SelectItem ¶
SelectItem represents an item in a selection list
type SelectModel ¶
type SelectModel[T any] struct { // Result Result tui.Result[T] // contains filtered or unexported fields }
SelectModel is the bubbletea model for selection
type SelectOptions ¶
type SelectOptions struct {
Initial any // Initial selection value
PageSize int // Number of items to show (default: 8)
ShowHelp bool // Show help footer (default: true)
CanGoBack bool // Allow back navigation (default: true)
BackLabel string // Label for back action (default: "Back")
EmptyLabel string // Label when no items
}
SelectOptions for customization
type Step ¶
type Step[T any] struct { Name string // Step name shown in UI Skip func(state T) bool // Return true to skip this step Execute func(ctx context.Context, state T) (T, StepResult, error) }
Step defines a single step in the wizard
type StepResult ¶
type StepResult int
StepResult indicates what the wizard should do after a step
const ( StepContinue StepResult = iota // Move to next step StepBack // Go back to previous step StepDone // Wizard complete StepSkip // Skip this step StepCancel // User cancelled )
type Wizard ¶
type Wizard[T any] struct { // contains filtered or unexported fields }
Wizard manages multi-step flows with back navigation
type WizardOption ¶
WizardOption for customizing wizard behavior
func WithTitle ¶
func WithTitle[T any](title string) WizardOption[T]
WithTitle sets the wizard title