Documentation
¶
Overview ¶
Package tuicore provides shared TUI form components for CLI commands.
Index ¶
- type ConfigState
- func (s *ConfigState) IsDirty(field string) bool
- func (s *ConfigState) MarkDirty(field string)
- func (s *ConfigState) UpdateAuthProviderFromForm(id string, form *FormModel)
- func (s *ConfigState) UpdateConfigFromForm(form *FormModel)
- func (s *ConfigState) UpdateMCPServerFromForm(name string, form *FormModel)
- func (s *ConfigState) UpdateProviderFromForm(id string, form *FormModel)
- type Field
- func BoolInput(key, label string, checked bool, desc string) *Field
- func IntInput(key, label string, value int, desc string) *Field
- func PasswordInput(key, label, value, desc string) *Field
- func SearchSelectInput(key, label, value string, options []string, desc string) *Field
- func SelectInput(key, label, value string, options []string, desc string) *Field
- func TextInput(key, label, value, desc string) *Field
- func TextInputWithPlaceholder(key, label, value, placeholder, desc string) *Field
- type FieldOptionsLoadedMsg
- type FormModel
- type InputType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigState ¶
ConfigState holds the current configuration state and tracking for dirty fields.
func NewConfigState ¶
func NewConfigState() *ConfigState
NewConfigState creates a new state with default config.
func NewConfigStateWith ¶
func NewConfigStateWith(cfg *config.Config) *ConfigState
NewConfigStateWith creates a new state with the given config.
func (*ConfigState) IsDirty ¶
func (s *ConfigState) IsDirty(field string) bool
IsDirty checks if a field is modified.
func (*ConfigState) MarkDirty ¶
func (s *ConfigState) MarkDirty(field string)
MarkDirty marks a field as modified.
func (*ConfigState) UpdateAuthProviderFromForm ¶
func (s *ConfigState) UpdateAuthProviderFromForm(id string, form *FormModel)
UpdateAuthProviderFromForm updates a specific OIDC provider config from the form.
func (*ConfigState) UpdateConfigFromForm ¶
func (s *ConfigState) UpdateConfigFromForm(form *FormModel)
UpdateConfigFromForm updates the config based on the form fields.
func (*ConfigState) UpdateMCPServerFromForm ¶ added in v0.4.0
func (s *ConfigState) UpdateMCPServerFromForm(name string, form *FormModel)
UpdateMCPServerFromForm updates a specific MCP server config from the form.
func (*ConfigState) UpdateProviderFromForm ¶
func (s *ConfigState) UpdateProviderFromForm(id string, form *FormModel)
UpdateProviderFromForm updates a specific provider config from the form.
type Field ¶
type Field struct {
Key string
Label string
Description string // Help text shown below the focused field
Type InputType
Value string
Placeholder string
Options []string // For InputSelect and InputSearchSelect
Checked bool // For InputBool
Width int
Validate func(string) error
// VisibleWhen controls conditional visibility. When non-nil, the field is
// shown only when this function returns true. When nil the field is always visible.
VisibleWhen func() bool
// OnChange is called when the field value changes (e.g. InputSelect left/right).
// The returned tea.Cmd (if non-nil) is executed asynchronously by the runtime.
OnChange func(newValue string) tea.Cmd
// Loading indicates an async operation (e.g. model fetch) is in progress.
Loading bool
// LoadError holds the last async fetch error for display.
LoadError error
// TextInput holds the bubbletea text input model (exported for cross-package use).
TextInput textinput.Model
Err error
// InputSearchSelect state
FilteredOptions []string // Filtered subset of Options
SelectCursor int // Cursor position in filtered list
SelectOpen bool // Whether dropdown is open
}
Field represents a single configuration field in a form.
func IntInput ¶ added in v0.7.0
IntInput creates an integer input field with positive-integer validation.
func PasswordInput ¶ added in v0.7.0
PasswordInput creates a password input field.
func SearchSelectInput ¶ added in v0.7.0
SearchSelectInput creates a searchable select field.
func SelectInput ¶ added in v0.7.0
SelectInput creates a select field with a list of options.
func TextInput ¶ added in v0.7.0
TextInput creates a text input field with the given key, label, value, and description.
func TextInputWithPlaceholder ¶ added in v0.7.0
TextInputWithPlaceholder creates a text input field with a placeholder hint.
type FieldOptionsLoadedMsg ¶ added in v0.4.0
type FieldOptionsLoadedMsg struct {
FieldKey string // target field Key
ProviderID string // provider at request time (race-condition guard)
Options []string // fetched options (nil on error)
Err error // fetch error, if any
}
FieldOptionsLoadedMsg is sent when an asynchronous model fetch completes. ProviderID is recorded at request time so stale results (from a previously selected provider) can be safely ignored.
type FormModel ¶
type FormModel struct {
Title string
Fields []*Field
Cursor int // index into VisibleFields()
Focus bool
OnSave func(map[string]interface{})
OnCancel func()
}
FormModel manages a list of fields.
func NewFormModel ¶
NewFormModel creates a new form with the given title.
func (*FormModel) AddField ¶
AddField adds a field to the form, initializing its text input if applicable.
func (FormModel) HasOpenDropdown ¶
HasOpenDropdown reports whether any field has an open search-select dropdown.
func (FormModel) VisibleFields ¶
VisibleFields returns only the fields that pass their visibility check.