form

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Show

func Show(parameters []internalModel.Parameter, values []internalModel.ParameterValue, okButton string, options ...Option) ([]string, bool)

Show displays a parameter collection form and returns the collected values.

Types

type FieldKeyMap added in v1.3.0

type FieldKeyMap struct {
	// Keybindings used when browsing the list.
	CursorUp        key.Binding
	CursorDown      key.Binding
	Apply           key.Binding
	ApplyCompletion key.Binding // Right arrow to apply without navigating

	// The quit keybinding. This won't be caught when filtering.
	Quit key.Binding
}

FieldKeyMap defines keybindings. It satisfies to the help.KeyMap interface, which is used to render the menu menu.

type FieldModel added in v1.8.0

type FieldModel struct {
	Label         string
	Description   string
	ParameterType appModel.ParameterType
	// contains filtered or unexported fields
}

FieldModel represents a single parameter input field.

func NewField added in v1.3.0

func NewField(
	styler style.Style,
	label,
	description string,
	paramType appModel.ParameterType,
	options []string,
	fs afero.Fs,
) *FieldModel

func (*FieldModel) Blur added in v1.8.0

func (m *FieldModel) Blur()

func (*FieldModel) Focus added in v1.8.0

func (m *FieldModel) Focus() tea.Cmd

func (*FieldModel) HasOptionToApply added in v1.8.0

func (m *FieldModel) HasOptionToApply() bool

func (*FieldModel) SetLabelWidth added in v1.8.0

func (m *FieldModel) SetLabelWidth(width int)

func (*FieldModel) SetValue added in v1.8.0

func (m *FieldModel) SetValue(text string)

func (*FieldModel) Update added in v1.8.0

func (m *FieldModel) Update(msg tea.Msg) (*FieldModel, tea.Cmd)

func (*FieldModel) Value added in v1.8.0

func (m *FieldModel) Value() string

func (*FieldModel) View added in v1.8.0

func (m *FieldModel) View() string

type KeyMap

type KeyMap struct {
	// Keybindings used when browsing the list.
	CursorUp   key.Binding
	CursorDown key.Binding
	Yes        key.Binding
	No         key.Binding
	Apply      key.Binding
	Next       key.Binding

	// The quit keybinding. This won't be caught when filtering.
	Quit key.Binding
}

KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which is used to render the menu menu.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a functional option for configuring the form.

func WithFS added in v1.3.0

func WithFS(fs afero.Fs) Option

WithFS sets the filesystem for the form.

func WithIn

func WithIn(input io.Reader) Option

WithIn sets the input reader for the form.

func WithOut

func WithOut(out io.Writer) Option

WithOut sets the output writer for the form.

func WithStyler

func WithStyler(styler style.Style) Option

WithStyler sets the styler for the form.

type ParameterModal added in v1.8.0

type ParameterModal struct {
	// contains filtered or unexported fields
}

ParameterModal is a reusable component for collecting parameter values.

func NewParameterModal added in v1.8.0

func NewParameterModal(
	parameters []appModel.Parameter,
	values []appModel.ParameterValue,
	config ParameterModalConfig,
	styler style.Style,
	fs afero.Fs,
) *ParameterModal

NewParameterModal creates a new parameter modal with the given configuration.

func (*ParameterModal) GetButtonFocus added in v1.8.0

func (m *ParameterModal) GetButtonFocus() int

GetButtonFocus returns the current button focus index (for testing).

func (*ParameterModal) GetElementFocus added in v1.8.0

func (m *ParameterModal) GetElementFocus() int

GetElementFocus returns the current element focus index (for testing).

func (*ParameterModal) GetFocusArea added in v1.8.0

func (m *ParameterModal) GetFocusArea() int

GetFocusArea returns the current focus area (for testing).

func (*ParameterModal) GetValues added in v1.8.0

func (m *ParameterModal) GetValues() []string

GetValues returns the collected parameter values.

func (*ParameterModal) Init added in v1.8.0

func (m *ParameterModal) Init() tea.Cmd

Init initializes the modal.

func (*ParameterModal) IsCanceled added in v1.8.0

func (m *ParameterModal) IsCanceled() bool

IsCanceled returns true if the user canceled the form.

func (*ParameterModal) IsSubmitted added in v1.8.0

func (m *ParameterModal) IsSubmitted() bool

IsSubmitted returns true if the user submitted the form.

func (*ParameterModal) SetButtonFocus added in v1.8.0

func (m *ParameterModal) SetButtonFocus(focus int)

SetButtonFocus sets the button focus index (for testing).

func (*ParameterModal) SetElementFocus added in v1.8.0

func (m *ParameterModal) SetElementFocus(focus int)

SetElementFocus sets the element focus index (for testing).

func (*ParameterModal) SetFocusArea added in v1.8.0

func (m *ParameterModal) SetFocusArea(area int)

SetFocusArea sets the focus area (for testing).

func (*ParameterModal) Update added in v1.8.0

func (m *ParameterModal) Update(msg tea.Msg) (*ParameterModal, tea.Cmd)

Update handles messages for the modal.

func (*ParameterModal) View added in v1.8.0

func (m *ParameterModal) View(terminalWidth, terminalHeight int) string

View renders the modal.

type ParameterModalConfig added in v1.8.0

type ParameterModalConfig struct {
	Title         string // Modal title (e.g., "Script Parameters")
	OkButtonText  string // Primary button text (e.g., "Execute", "Apply")
	OkShortcut    string // Keyboard shortcut for OK button (e.g., "e", "a")
	ShowAllFields bool   // true = show all fields at once, false = progressive display
	EmbeddedMode  bool   // true = embedded in larger UI, false = standalone program
}

ParameterModalConfig configures the behavior and appearance of a parameter modal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL