Documentation
¶
Overview ¶
Package framework provides the core wizard orchestration system.
A wizard is a multi-step interactive flow that guides users through complex operations. It manages step navigation, skip conditions, callbacks, and summary display.
Index ¶
- func BorderStyle() lipgloss.Style
- func ErrorStyle() lipgloss.Style
- func FilterLabelStyle() lipgloss.Style
- func FilterRunes(runes []rune, filter RuneFilter) string
- func FilterStyle() lipgloss.Style
- func HelpStyle() lipgloss.Style
- func InfoStyle() lipgloss.Style
- func MatchHighlightStyle() lipgloss.Style
- func OptionDescriptionStyle() lipgloss.Style
- func OptionDisabledStyle() lipgloss.Style
- func OptionNormalStyle() lipgloss.Style
- func OptionSelectedStyle() lipgloss.Style
- func RuneFilterNoSpaces(r rune) bool
- func RuneFilterNone(r rune) bool
- func StepActiveStyle() lipgloss.Style
- func StepArrowStyle() lipgloss.Style
- func StepCheckStyle() lipgloss.Style
- func StepCompletedStyle() lipgloss.Style
- func StepInactiveStyle() lipgloss.Style
- func SummaryLabelStyle() lipgloss.Style
- func SummaryValueStyle() lipgloss.Style
- func TitleStyle() lipgloss.Style
- type Option
- type RuneFilter
- type Step
- type StepResult
- type StepValue
- type Wizard
- func (w *Wizard) AddStep(step Step) *Wizard
- func (w *Wizard) AllStepsComplete() bool
- func (w *Wizard) CurrentStepID() string
- func (w *Wizard) GetBool(id string) bool
- func (w *Wizard) GetStep(id string) Step
- func (w *Wizard) GetString(id string) string
- func (w *Wizard) GetStrings(id string) []string
- func (w *Wizard) GetValue(id string) StepValue
- func (w *Wizard) Init() tea.Cmd
- func (w *Wizard) IsCancelled() bool
- func (w *Wizard) OnComplete(stepID string, callback func(*Wizard)) *Wizard
- func (w *Wizard) Run() (*Wizard, error)
- func (w *Wizard) SetCurrentStep(id string)
- func (w *Wizard) SkipWhen(stepID string, condition func(*Wizard) bool) *Wizard
- func (w *Wizard) StepCount() int
- func (w *Wizard) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (w *Wizard) View() tea.View
- func (w *Wizard) WithInfoLine(fn func(*Wizard) string) *Wizard
- func (w *Wizard) WithSkipSummary(skip bool) *Wizard
- func (w *Wizard) WithSummary(title string) *Wizard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BorderStyle ¶
BorderStyle wraps the entire wizard (left border only)
func ErrorStyle ¶ added in v0.14.0
ErrorStyle for validation error messages
func FilterLabelStyle ¶
FilterLabelStyle for the "Filter:" label
func FilterRunes ¶
func FilterRunes(runes []rune, filter RuneFilter) string
FilterRunes returns characters from a rune slice that pass the filter. If filter is nil, defaults to RuneFilterNone (all printable).
func MatchHighlightStyle ¶
MatchHighlightStyle for highlighting fuzzy matched characters
func OptionDescriptionStyle ¶
OptionDescriptionStyle for two-row option descriptions
func OptionDisabledStyle ¶
OptionDisabledStyle for disabled/greyed options
func OptionNormalStyle ¶
OptionNormalStyle for regular options
func OptionSelectedStyle ¶
OptionSelectedStyle for the cursor-highlighted option
func RuneFilterNoSpaces ¶
RuneFilterNoSpaces allows printable characters except spaces. Use for branch names, identifiers, etc.
func RuneFilterNone ¶
RuneFilterNone allows all printable characters.
func StepActiveStyle ¶
StepActiveStyle for the current step tab
func StepCheckStyle ¶
StepCheckStyle for the checkmark on completed steps
func StepCompletedStyle ¶
StepCompletedStyle for completed step tabs
func StepInactiveStyle ¶
StepInactiveStyle for unvisited step tabs
func SummaryLabelStyle ¶
SummaryLabelStyle for summary field labels
func SummaryValueStyle ¶
SummaryValueStyle for summary field values
Types ¶
type Option ¶
type Option struct {
Label string // Display text
Value any // Actual value
Description string // Optional description (for disabled reason)
Disabled bool // Whether option is disabled/unselectable
}
Option represents a selectable item in list-based steps.
type RuneFilter ¶
RuneFilter determines which runes are allowed in input.
type Step ¶
type Step interface {
// ID returns a unique identifier for this step.
ID() string
// Title returns the display title for the step tab.
Title() string
// Init returns an initial command when entering this step.
Init() tea.Cmd
// Update handles key events and returns the updated step,
// a command to run, and a result indicating navigation.
Update(msg tea.KeyPressMsg) (Step, tea.Cmd, StepResult)
// View renders the step content.
View() string
// Help returns the help text for this step.
Help() string
// Value returns the step's current value for summary display.
Value() StepValue
// IsComplete returns true if the step has a valid selection.
IsComplete() bool
// Reset clears the step's selection/input.
Reset()
// HasClearableInput returns true if the step has input that can be cleared.
// Used to determine ESC behavior: clear input first, then cancel.
HasClearableInput() bool
// ClearInput clears any user input (filter, text field, etc).
// Returns a command to run (e.g., textinput.Blink for cursor).
ClearInput() tea.Cmd
}
Step is the interface for wizard steps.
type StepResult ¶
type StepResult int
StepResult indicates what action to take after a step update.
const ( // StepContinue means stay on the current step. StepContinue StepResult = iota // StepAdvance means move to the next step. StepAdvance // StepBack means move to the previous step. StepBack // StepSubmitIfReady means advance to the next step; if this was the last step, the wizard finishes. StepSubmitIfReady )
type StepValue ¶
type StepValue struct {
Key string // Field name (e.g., "Branch")
Label string // Display value (e.g., "feature-branch")
Raw any // Actual value (can be string, bool, []string, etc.)
}
StepValue holds the result of a completed step.
type Wizard ¶
type Wizard struct {
// contains filtered or unexported fields
}
Wizard orchestrates a multi-step interactive flow.
func (*Wizard) AllStepsComplete ¶
AllStepsComplete returns true if all steps have values.
func (*Wizard) CurrentStepID ¶
CurrentStepID returns the current step's ID, or "summary" if on summary.
func (*Wizard) GetStrings ¶
GetStrings returns a step's value as a string slice.
func (*Wizard) IsCancelled ¶
IsCancelled returns true if the wizard was cancelled.
func (*Wizard) OnComplete ¶
OnComplete sets a callback to run when a step completes.
func (*Wizard) Run ¶
Run executes the wizard and returns when complete or cancelled. The TUI renders to stderr so stdout remains available for piping (e.g., cd $(wt cd -i) works correctly).
func (*Wizard) SetCurrentStep ¶
SetCurrentStep sets the current step by ID.
func (*Wizard) WithInfoLine ¶
WithInfoLine sets a dynamic info line function.
func (*Wizard) WithSkipSummary ¶
WithSkipSummary sets whether to skip the summary step and finish after the last step. Useful for single-step wizards where a confirmation summary is unnecessary.
func (*Wizard) WithSummary ¶
WithSummary sets the summary step title.