Documentation
¶
Index ¶
- Constants
- func AddWizardFlag(cmd *cobra.Command)
- func ApplyResultToFlags(cmd *cobra.Command, result map[string]any) error
- func EnableWizard(cmd *cobra.Command)
- func EnableWizardForCommands(cmds ...*cobra.Command)
- func RegisterDefaultProvider(flagName string, fn DefaultProvider)
- func RegisterDefaultProviderForCommand(cmd *cobra.Command, flagName string, fn DefaultProvider)
- func RegisterProvider(flagName string, fn OptionProvider)
- func RegisterProviderForCommand(cmd *cobra.Command, flagName string, fn OptionProvider)
- func RunWizard(cmd *cobra.Command) (map[string]any, error)
- func WrapPreRunEWithWizard(originalPreRunE func(cmd *cobra.Command, args []string) error, ...) func(cmd *cobra.Command, args []string) error
- func WrapRunEWithWizard(originalRunE func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error
- type DefaultProvider
- type FieldKind
- type FormField
- type FormGroup
- type FormTheme
- type GroupedWizardForm
- func (f *GroupedWizardForm) Aborted() bool
- func (f *GroupedWizardForm) Init() tea.Cmd
- func (f *GroupedWizardForm) Run() error
- func (f *GroupedWizardForm) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (f *GroupedWizardForm) View() string
- func (f *GroupedWizardForm) WithFormTheme(theme *FormTheme) *GroupedWizardForm
- func (f *GroupedWizardForm) WithTheme(theme *huh.Theme) *GroupedWizardForm
- type OptionProvider
Constants ¶
const DefaultFlagOrder = 9999
DefaultFlagOrder is the default order value for flags without explicit ordering
Variables ¶
This section is empty.
Functions ¶
func AddWizardFlag ¶
AddWizardFlag adds the --wizard flag to a command
func ApplyResultToFlags ¶
ApplyResultToFlags applies wizard results back to command flags
func EnableWizard ¶
EnableWizard adds --wizard flag and wraps PreRunE for a command This is a convenience function that combines AddWizardFlag and WrapPreRunEWithWizard
func EnableWizardForCommands ¶
EnableWizardForCommands enables wizard for multiple commands
func RegisterDefaultProvider ¶
func RegisterDefaultProvider(flagName string, fn DefaultProvider)
RegisterDefaultProvider registers a default value provider for a flag name
func RegisterDefaultProviderForCommand ¶
func RegisterDefaultProviderForCommand(cmd *cobra.Command, flagName string, fn DefaultProvider)
RegisterDefaultProviderForCommand registers a default value provider scoped to a command and its children.
func RegisterProvider ¶
func RegisterProvider(flagName string, fn OptionProvider)
RegisterProvider registers a dynamic option provider for a flag name
func RegisterProviderForCommand ¶
func RegisterProviderForCommand(cmd *cobra.Command, flagName string, fn OptionProvider)
RegisterProviderForCommand registers a dynamic option provider scoped to a command and its children.
func RunWizard ¶
RunWizard runs an interactive wizard for the given command's flags. It returns the collected values as a map, or an error if cancelled.
func WrapPreRunEWithWizard ¶
func WrapPreRunEWithWizard( originalPreRunE func(cmd *cobra.Command, args []string) error, originalPreRun func(cmd *cobra.Command, args []string), ) func(cmd *cobra.Command, args []string) error
WrapPreRunEWithWizard wraps a command's PreRunE to support wizard mode. Usage: cmd.PreRunE = wizard.WrapPreRunEWithWizard(originalPreRunE, originalPreRun)
Types ¶
type DefaultProvider ¶
type DefaultProvider func() string
DefaultProvider returns a dynamic default value for a flag
type FormField ¶
type FormField struct {
Name string
Title string
Description string
Kind FieldKind
Options []string // For Select/MultiSelect
Selected int // For Select: current selection index
MultiSelect map[int]bool // For MultiSelect: selected indices
InputValue string // For Input/Number
ConfirmVal bool // For Confirm
Required bool
Validate func(string) error
Value interface{} // Pointer to store result
}
FormField represents a field that can be displayed in the form
type FormGroup ¶
type FormGroup struct {
Name string
Title string
Description string
Fields []*FormField
Optional bool // If true, this group can be collapsed
Expanded bool // If true and Optional, show fields; otherwise collapsed
}
FormGroup represents a group of fields
type FormTheme ¶
type FormTheme struct {
TabActive lipgloss.Style
TabInactive lipgloss.Style
TabCompleted lipgloss.Style
Separator lipgloss.Style
Error lipgloss.Style
Help lipgloss.Style
FocusedTitle lipgloss.Style
NormalTitle lipgloss.Style
Description lipgloss.Style
SelectedOption lipgloss.Style
UnselectedOption lipgloss.Style
FocusedUnselected lipgloss.Style
MultiSelectChecked lipgloss.Style
InputFocused lipgloss.Style
InputBlurred lipgloss.Style
GroupHeader lipgloss.Style
GroupHeaderDim lipgloss.Style
}
FormTheme defines styles for the grouped wizard form
func DefaultFormTheme ¶
func DefaultFormTheme() *FormTheme
DefaultFormTheme returns the default theme for grouped wizard forms
type GroupedWizardForm ¶
type GroupedWizardForm struct {
// contains filtered or unexported fields
}
GroupedWizardForm is a single-page wizard form with all groups visible
func NewGroupedWizardForm ¶
func NewGroupedWizardForm(groups []*FormGroup) *GroupedWizardForm
NewGroupedWizardForm creates a new grouped wizard form
func (*GroupedWizardForm) Aborted ¶
func (f *GroupedWizardForm) Aborted() bool
Aborted returns true if the user cancelled
func (*GroupedWizardForm) Init ¶
func (f *GroupedWizardForm) Init() tea.Cmd
Init implements tea.Model
func (*GroupedWizardForm) Run ¶
func (f *GroupedWizardForm) Run() error
Run executes the grouped form
func (*GroupedWizardForm) View ¶
func (f *GroupedWizardForm) View() string
View implements tea.Model - renders all groups on a single page
func (*GroupedWizardForm) WithFormTheme ¶
func (f *GroupedWizardForm) WithFormTheme(theme *FormTheme) *GroupedWizardForm
WithFormTheme sets the form theme for styling
func (*GroupedWizardForm) WithTheme ¶
func (f *GroupedWizardForm) WithTheme(theme *huh.Theme) *GroupedWizardForm
WithTheme sets the huh theme
type OptionProvider ¶
type OptionProvider func() []string
OptionProvider returns dynamic options for a flag's select menu