ui

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MPL-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Package ui implements the terramate ui command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDisplayValue

func FormatDisplayValue(val cty.Value, typ typeschema.Type) string

FormatDisplayValue renders a one-line display string for a cty.Value using the typeschema.Type to provide richer formatting for complex types.

func IsBundleUnique

func IsBundleUnique(r *config.Registry, alias, classID, hostPath string, env *config.Environment) error

IsBundleUnique checks that no existing bundle conflicts with the given alias and class.

Types

type BoolWidget

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

BoolWidget provides a Yes/No toggle.

func NewBoolWidget

func NewBoolWidget(wctx *WidgetContext) *BoolWidget

NewBoolWidget creates a Yes/No toggle widget.

func (*BoolWidget) AcceptSubFormResult

func (w *BoolWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; bool widgets do not use sub-forms.

func (*BoolWidget) FormatDisplay

func (w *BoolWidget) FormatDisplay() string

FormatDisplay returns a display string for the current boolean value.

func (*BoolWidget) ForwardMsg

func (w *BoolWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; bool widgets have no underlying input component.

func (*BoolWidget) Prepare

func (w *BoolWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*BoolWidget) Render

func (w *BoolWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*BoolWidget) Update

func (w *BoolWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*BoolWidget) WidgetContext

func (w *BoolWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type BundleOption

type BundleOption struct {
	Name  string
	Alias string
	EnvID string
}

BundleOption is a unified representation of a selectable bundle for the bundle-ref widget, covering both existing on-disk bundles and session-created ones.

func MatchingBundleOptions

func MatchingBundleOptions(r *config.Registry, classID string, env *config.Environment) []BundleOption

MatchingBundleOptions returns bundles that match the given class ID and environment.

type BundleRefListWidget added in v0.17.3

type BundleRefListWidget struct {
	PendingRefClass string
	// contains filtered or unexported fields
}

BundleRefListWidget lets the user pick any number of bundles of one class.

func NewBundleRefListWidget added in v0.17.3

func NewBundleRefListWidget(wctx *WidgetContext, classID string) *BundleRefListWidget

NewBundleRefListWidget creates a widget for selecting multiple bundle references.

func (*BundleRefListWidget) AcceptCreatedBundleRef added in v0.17.3

func (w *BundleRefListWidget) AcceptCreatedBundleRef(alias string) bool

AcceptCreatedBundleRef adds the newly created bundle to the selection. The input stays active so that more references can be added.

func (*BundleRefListWidget) AcceptSubFormResult added in v0.17.3

func (w *BundleRefListWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; bundle-ref lists do not use sub-forms.

func (*BundleRefListWidget) FormatDisplay added in v0.17.3

func (w *BundleRefListWidget) FormatDisplay() string

FormatDisplay returns a comma-separated summary of the selected bundles.

func (*BundleRefListWidget) ForwardMsg added in v0.17.3

func (w *BundleRefListWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; bundle-ref lists have no underlying input component.

func (*BundleRefListWidget) HelpHints added in v0.17.3

func (w *BundleRefListWidget) HelpHints() string

HelpHints returns the key hints shown in the bottom help line while the bundle multi-select is the active input. The "Add new" row speaks for itself, so it drops the hints rather than repeating what its label already says - and the selection hints would be wrong there anyway.

func (*BundleRefListWidget) Prepare added in v0.17.3

func (w *BundleRefListWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*BundleRefListWidget) Reload added in v0.17.3

func (w *BundleRefListWidget) Reload()

Reload syncs the widget's internal state from the WidgetContext value.

func (*BundleRefListWidget) Render added in v0.17.3

func (w *BundleRefListWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*BundleRefListWidget) Update added in v0.17.3

func (w *BundleRefListWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*BundleRefListWidget) WidgetContext added in v0.17.3

func (w *BundleRefListWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type BundleRefWidget

type BundleRefWidget struct {
	PendingRefClass string
	// contains filtered or unexported fields
}

BundleRefWidget lets the user pick an existing created bundle or create a new one.

func NewBundleRefWidget

func NewBundleRefWidget(wctx *WidgetContext, classID string) *BundleRefWidget

NewBundleRefWidget creates a widget for selecting or creating a bundle reference.

func (*BundleRefWidget) AcceptCreatedBundleRef added in v0.17.3

func (w *BundleRefWidget) AcceptCreatedBundleRef(alias string) bool

AcceptCreatedBundleRef makes the newly created bundle the value of the input, which completes it.

func (*BundleRefWidget) AcceptSubFormResult

func (w *BundleRefWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; bundle-ref widgets do not use sub-forms.

func (*BundleRefWidget) FormatDisplay

func (w *BundleRefWidget) FormatDisplay() string

FormatDisplay returns a display string for the selected bundle reference.

func (*BundleRefWidget) ForwardMsg

func (w *BundleRefWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; bundle-ref widgets have no underlying input component.

func (*BundleRefWidget) Prepare

func (w *BundleRefWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*BundleRefWidget) Reload

func (w *BundleRefWidget) Reload()

Reload syncs the widget's internal state from the WidgetContext value.

func (*BundleRefWidget) Render

func (w *BundleRefWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*BundleRefWidget) Update

func (w *BundleRefWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*BundleRefWidget) WidgetContext

func (w *BundleRefWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type Change

type Change struct {
	Kind        ChangeKind
	HostPath    string
	ProjectPath string
	Name        string
	UUID        string
	Source      string
	Alias       string

	DisplayName string
	Metadata    config.Metadata

	BundleDefEntry *config.BundleDefinitionEntry
	InputDefs      []*config.InputDefinition // Original input definitions
	Values         map[string]cty.Value      // All values (user + defaults) for validation
	UserValues     map[string]cty.Value      // Only user-set values (written to YAML)

	// Schemactx is the context the values were evaluated in. It is needed to
	// walk input types when writing the values back out, e.g. to translate
	// resolved bundle references back into keys.
	Schemactx typeschema.EvalContext

	Env     *config.Environment
	FromEnv *config.Environment

	OriginalBundle *config.Bundle       // Only set for reconfig and promote
	OriginalValues map[string]cty.Value // Baseline values from disk (for change detection)

	Warnings []string // Non-fatal warnings surfaced after resolving the change

}

Change represents a bundle change (create, reconfigure, or promote).

func NewCreateChange

func NewCreateChange(
	est *EngineState,
	activeEnv *config.Environment,
	bde *config.BundleDefinitionEntry,
	schemactx typeschema.EvalContext,
	inputDefs []*config.InputDefinition,
	values map[string]cty.Value,
) (Change, error)

NewCreateChange builds a Change that represents a new bundle creation.

func NewPromoteChange

func NewPromoteChange(
	est *EngineState,
	env *config.Environment,
	bundle *config.Bundle,
	bde *config.BundleDefinitionEntry,
	schemactx typeschema.EvalContext,
	inputDefs []*config.InputDefinition,
	values map[string]cty.Value,
) (Change, error)

NewPromoteChange builds a Change that represents promoting a bundle to another environment.

func NewReconfigChange

func NewReconfigChange(
	est *EngineState,
	bundle *config.Bundle,
	bde *config.BundleDefinitionEntry,
	schemactx typeschema.EvalContext,
	inputDefs []*config.InputDefinition,
	values map[string]cty.Value,
) (Change, error)

NewReconfigChange builds a Change that represents reconfiguring an existing bundle.

func (*Change) Save

func (c *Change) Save(envs []*config.Environment) error

Save writes the change to disk as a YAML bundle instance file.

type ChangeKind

type ChangeKind string

ChangeKind indicates the type of change.

const (
	ChangeCreate   ChangeKind = "change_create"
	ChangeReconfig ChangeKind = "change_reconfig"
	ChangePromote  ChangeKind = "change_promote"
)

ChangeCreate and the following constants enumerate the supported change kinds.

type CreateFrame

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

CreateFrame captures the wizard state when suspending for nested bundle creation.

type EngineState

type EngineState struct {
	Context         context.Context
	CLI             commands.CLI
	WorkingDir      string
	Root            *config.Root
	Evalctx         *eval.Context // This is the base evalctx. Should be cloned instead of modifie directly.
	ResolveAPI      resolve.API
	Registry        *config.Registry
	LocalBundleDefs []config.BundleDefinitionEntry
	Collections     []*manifest.Collection
	CLIConfig       cliconfig.Config
	AgentAddress    string
}

EngineState contains common engine state used throughout all layers.

None of these attributes should change after initialization, with the exception of Registry, which is reloaded after each save.

type FocusArea

type FocusArea int

FocusArea represents which section has focus in the overview.

const (
	FocusCommands FocusArea = iota
	FocusSummary
)

FocusCommands and the following constants enumerate the overview focus areas.

type HelpHinter added in v0.17.3

type HelpHinter interface {
	HelpHints() string
}

HelpHinter is an optional interface for widgets that contribute contextual key hints to the bottom help line while they are the active input. Hints use the same " • " separator as the rest of the help line.

type InlineListWidget

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

InlineListWidget manages a list of items that are edited inline. This supports strings and numbers.

func NewInlineListWidget

func NewInlineListWidget(wctx *WidgetContext, valueType typeschema.Type) *InlineListWidget

NewInlineListWidget creates a widget for editing a list of primitive values inline.

func (*InlineListWidget) AcceptSubFormResult

func (w *InlineListWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; inline lists do not use sub-forms.

func (*InlineListWidget) FormatDisplay

func (w *InlineListWidget) FormatDisplay() string

FormatDisplay returns a compact summary of the current list value.

func (*InlineListWidget) ForwardMsg

func (w *InlineListWidget) ForwardMsg(msg tea.Msg) tea.Cmd

ForwardMsg forwards a bubbletea message to the underlying text input.

func (*InlineListWidget) Prepare

func (w *InlineListWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*InlineListWidget) Render

func (w *InlineListWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*InlineListWidget) Update

func (w *InlineListWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*InlineListWidget) WidgetContext

func (w *InlineListWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type InlineMapWidget

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

InlineMapWidget manages a map of key-value pairs edited inline. This supports string and number values.

func NewInlineMapWidget

func NewInlineMapWidget(wctx *WidgetContext, valueType typeschema.Type) *InlineMapWidget

NewInlineMapWidget creates a widget for editing a map of primitive key-value pairs inline.

func (*InlineMapWidget) AcceptSubFormResult

func (w *InlineMapWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; inline map widgets do not use sub-forms.

func (*InlineMapWidget) FormatDisplay

func (w *InlineMapWidget) FormatDisplay() string

FormatDisplay returns a compact summary of the current map value.

func (*InlineMapWidget) ForwardMsg

func (w *InlineMapWidget) ForwardMsg(msg tea.Msg) tea.Cmd

ForwardMsg forwards a bubbletea message to the underlying text input.

func (*InlineMapWidget) Prepare

func (w *InlineMapWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*InlineMapWidget) Render

func (w *InlineMapWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*InlineMapWidget) Update

func (w *InlineMapWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*InlineMapWidget) WidgetContext

func (w *InlineMapWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type InputFocusArea

type InputFocusArea int

InputFocusArea represents which panel has focus in the split input view.

const (
	InputFocusActive    InputFocusArea = iota // Top panel: current input / buttons
	InputFocusCompleted                       // Bottom panel: completed inputs
)

InputFocusActive and the following constants define the input view focus areas.

type InputOption

type InputOption struct {
	Label string
	Value cty.Value
}

InputOption represents a selectable option for select/multiselect inputs.

type InputWidget

type InputWidget interface {
	// WidgetContext returns the widget context.
	WidgetContext() *WidgetContext

	// Prepare initializes the widget for active editing.
	Prepare()

	// Update handles a key event. Returns a signal and optional tea.Cmd.
	// When returning WidgetConfirmed, the widget must have already called
	// ctx.UpdateValue() successfully.
	Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

	// Render returns the lines for the active input area.
	Render() []string

	// FormatDisplay returns a short summary for the completed inputs panel.
	FormatDisplay() string

	// ForwardMsg forwards non-key messages (e.g. cursor blink) to internal controls.
	ForwardMsg(msg tea.Msg) tea.Cmd

	// AcceptSubFormResult receives the result from a completed sub-form.
	// Returns true if the widget is fully done (caller should confirm/advance),
	// or false if the widget stays active (e.g. list widget awaiting more items).
	AcceptSubFormResult(result SubFormResult) bool
}

InputWidget is the interface for composable input controls. Each widget encapsulates the prepare/update/render/value lifecycle for a specific input type. Container widgets (list, map, object) hold child widgets, enabling recursive type composition.

Widgets commit their value by calling ctx.UpdateValue() which writes the value into the WidgetContext and syncs it into the eval context for cross-input references. If validation fails the widget should store the error and render it, returning WidgetContinue.

func NewListWidget

func NewListWidget(wctx *WidgetContext, valTyp typeschema.Type) InputWidget

NewListWidget is a helper to select the appropriate list widget sub-type.

func NewMapWidget

func NewMapWidget(wctx *WidgetContext, valTyp typeschema.Type) InputWidget

NewMapWidget is a helper to select the appropriate map widget sub-type.

func NewSubFormListWidget

func NewSubFormListWidget(wctx *WidgetContext, valueType typeschema.Type) InputWidget

NewSubFormListWidget creates a widget for editing a list of complex items via nested sub-forms.

func NewSubFormMapWidget

func NewSubFormMapWidget(wctx *WidgetContext, valueType typeschema.Type) InputWidget

NewSubFormMapWidget creates a widget for editing a map of complex values via nested sub-forms.

func NewWidget

func NewWidget(wctx *WidgetContext, typ typeschema.Type) InputWidget

NewWidget creates the appropriate InputWidget for a typeschema.Type.

type InputsForm

type InputsForm struct {
	Schemactx typeschema.EvalContext
	InputDefs []*config.InputDefinition

	// Layout — dynamic panel dimensions; 0 means use defaults.
	PanelWidth  int
	PanelHeight int
	// contains filtered or unexported fields
}

InputsForm is a sub-model that handles sequential input forms in a scrollable canvas. Inputs are revealed one at a time. Previous answers are shown above. The user can navigate back to re-edit previous entries.

func NewInputsForm

func NewInputsForm(inputDefs []*config.InputDefinition, schemactx typeschema.EvalContext, registry *config.Registry, env *config.Environment) InputsForm

NewInputsForm creates a new inputs form for the given inputs and schemas

func NewInputsFormWithValues

func NewInputsFormWithValues(inputDefs []*config.InputDefinition, schemactx typeschema.EvalContext, registry *config.Registry, env, fromEnv *config.Environment, values, originalValues map[string]cty.Value, userKeys map[string]bool) InputsForm

NewInputsFormWithValues creates an inputs form pre-populated with existing values. userKeys, when non-nil, restricts which values are considered user-provided (vs default-seeded). When nil, all pre-existing values are treated as user-provided.

func (*InputsForm) ExtraHelpHints

func (f *InputsForm) ExtraHelpHints() string

ExtraHelpHints returns contextual help hints for the current state. The caller appends these to the help line.

func (*InputsForm) FocusActiveInput

func (f *InputsForm) FocusActiveInput() tea.Cmd

FocusActiveInput forwards a focus command to the active widget.

func (*InputsForm) ForwardMsg

func (f *InputsForm) ForwardMsg(msg tea.Msg) tea.Cmd

ForwardMsg forwards a non-key message to the active widget (cursor blink, etc).

func (*InputsForm) HasPendingChanges

func (f *InputsForm) HasPendingChanges() bool

HasPendingChanges returns true when any visible value differs from the original baseline. Only visible (condition-enabled) inputs are checked so that hidden inputs cleared as a side-effect of clearDependents do not keep buttons visible when the user reverts all visible values back to their originals. Always returns false when not in reconfiguring mode.

func (*InputsForm) HighlightedInputName

func (f *InputsForm) HighlightedInputName() string

HighlightedInputName returns the Name of the input currently under the cursor in the completed panel, or "" if nothing is highlighted.

func (*InputsForm) IsConfirmingDiscard

func (f *InputsForm) IsConfirmingDiscard() bool

IsConfirmingDiscard returns true if the discard confirmation prompt is active.

func (*InputsForm) IsEditingInput

func (f *InputsForm) IsEditingInput() bool

IsEditingInput returns true when the user is actively editing an individual input (as opposed to browsing the completed list or sitting on the action buttons).

func (*InputsForm) IsMultilineActive

func (f *InputsForm) IsMultilineActive() bool

IsMultilineActive returns true when the current input is a multiline textarea.

func (*InputsForm) PendingRefClass

func (f *InputsForm) PendingRefClass() string

PendingRefClass returns the RefClass for InputsFormCreateRef state.

func (*InputsForm) PendingSubForm

func (f *InputsForm) PendingSubForm() *SubFormRequest

PendingSubForm returns the SubFormRequest from the active widget. Non-nil only when state is InputsFormEditObject.

func (*InputsForm) ReenterAt

func (f *InputsForm) ReenterAt(idx int)

ReenterAt resets the form to the given input index, preserving values before that index and keeping existing values for later inputs so they pre-populate. The form resumes normal sequential flow from idx onward.

func (*InputsForm) Remaining

func (f *InputsForm) Remaining() int

Remaining returns the number of visible inputs that have not been filled yet.

func (*InputsForm) SeedValues

func (f *InputsForm) SeedValues(vals map[string]cty.Value)

SeedValues sets initial values onto widgets without triggering side effects. Used when opening a sub-form with pre-existing values.

func (*InputsForm) SetValidationError

func (f *InputsForm) SetValidationError(err error)

SetValidationError sets an error to display at the top of the completed panel. The error is cleared automatically on the next key press.

func (*InputsForm) ShowsTwoPanels

func (f *InputsForm) ShowsTwoPanels() bool

ShowsTwoPanels returns true when the form is displaying the split two-panel layout.

func (*InputsForm) State

func (f *InputsForm) State() InputsFormState

State returns the result state of the form.

func (*InputsForm) TriggerDiscard

func (f *InputsForm) TriggerDiscard()

TriggerDiscard activates the discard confirmation prompt (same as pressing Cancel).

func (InputsForm) Update

func (f InputsForm) Update(msg tea.Msg) (InputsForm, tea.Cmd)

Update handles messages for the inputs form.

func (*InputsForm) UserValues

func (f *InputsForm) UserValues() map[string]cty.Value

UserValues returns only the values that were explicitly set by the user, excluding default-seeded values. Used when writing to YAML so that defaults are evaluated at runtime rather than baked into the config.

func (*InputsForm) Values

func (f *InputsForm) Values() map[string]cty.Value

Values returns a copy of the collected input values, excluding synthetic keys injected by the caller.

func (InputsForm) View

func (f InputsForm) View() string

View renders the inputs form as two bordered panels:

  • Top panel: the current active input (or action buttons when done)
  • Bottom panel: already-completed inputs (scrollable, navigable when focused)

Review mode (edit-change) renders a single review list instead.

type InputsFormState

type InputsFormState int

InputsFormState represents the current state of the inputs form.

const (
	InputsFormActive InputsFormState = iota
	InputsFormAccepted
	InputsFormDiscarded
	InputsFormCreateRef // Signals parent to push state and start nested bundle creation
	InputsFormSubForm   // Signals parent to open nested form
)

InputsFormActive and the following constants define the inputs form states.

type Model

type Model struct {

	// Common state
	EngineState *EngineState
	// contains filtered or unexported fields
}

Model is the main BubbleTea model for the prompt UI.

func NewModel

func NewModel(est *EngineState) Model

NewModel creates a new prompt model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the model.

func (Model) View

func (m Model) View() string

View renders the current view.

type MultiSelectWidget

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

MultiSelectWidget provides a cursor-based multi-select with checkboxes.

func NewMultiSelectWidget

func NewMultiSelectWidget(wctx *WidgetContext) *MultiSelectWidget

NewMultiSelectWidget creates a multi-select option list widget with checkboxes.

func (*MultiSelectWidget) AcceptSubFormResult

func (w *MultiSelectWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; multi-select widgets do not use sub-forms.

func (*MultiSelectWidget) FormatDisplay

func (w *MultiSelectWidget) FormatDisplay() string

FormatDisplay returns a comma-separated display string of the selected options.

func (*MultiSelectWidget) ForwardMsg

func (w *MultiSelectWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; multi-select widgets have no underlying input component.

func (*MultiSelectWidget) HelpHints added in v0.17.3

func (w *MultiSelectWidget) HelpHints() string

HelpHints returns the key hints shown in the bottom help line while the multi-select is the active input.

func (*MultiSelectWidget) Prepare

func (w *MultiSelectWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*MultiSelectWidget) Render

func (w *MultiSelectWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*MultiSelectWidget) Update

func (w *MultiSelectWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*MultiSelectWidget) WidgetContext

func (w *MultiSelectWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type MultilineWidget

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

MultilineWidget wraps a textarea.Model for multi-line text inputs.

func NewMultilineWidget

func NewMultilineWidget(wctx *WidgetContext) *MultilineWidget

NewMultilineWidget creates a multi-line text area widget.

func (*MultilineWidget) AcceptSubFormResult

func (w *MultilineWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; multiline widgets do not use sub-forms.

func (*MultilineWidget) FormatDisplay

func (w *MultilineWidget) FormatDisplay() string

FormatDisplay returns a truncated display string for the current value.

func (*MultilineWidget) ForwardMsg

func (w *MultilineWidget) ForwardMsg(msg tea.Msg) tea.Cmd

ForwardMsg forwards a bubbletea message to the underlying text area.

func (*MultilineWidget) Prepare

func (w *MultilineWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*MultilineWidget) Render

func (w *MultilineWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*MultilineWidget) Update

func (w *MultilineWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*MultilineWidget) WidgetContext

func (w *MultilineWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type ObjectEditFrame

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

ObjectEditFrame captures the form state when suspending for nested object editing.

type ObjectWidget

type ObjectWidget struct {

	// SubFormRequest is populated when the widget signals WidgetNeedSubForm.
	SubFormRequest *SubFormRequest
	// contains filtered or unexported fields
}

ObjectWidget manages a structured object with named fields. It signals WidgetNeedSubForm to open a nested form for editing the object's attributes, since objects use the full InputsForm for their sub-inputs.

func NewObjectWidget

func NewObjectWidget(wctx *WidgetContext, objType *typeschema.ObjectType) *ObjectWidget

NewObjectWidget creates a widget for editing a structured object via a nested sub-form.

func (*ObjectWidget) AcceptSubFormResult

func (w *ObjectWidget) AcceptSubFormResult(result SubFormResult) bool

AcceptSubFormResult integrates a completed sub-form result into the object value.

func (*ObjectWidget) FormatDisplay

func (w *ObjectWidget) FormatDisplay() string

FormatDisplay returns a display string for the current object value.

func (*ObjectWidget) ForwardMsg

func (w *ObjectWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; object widgets have no underlying input component.

func (*ObjectWidget) Prepare

func (w *ObjectWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*ObjectWidget) Render

func (w *ObjectWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*ObjectWidget) Update

func (w *ObjectWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*ObjectWidget) WidgetContext

func (w *ObjectWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type SelectWidget

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

SelectWidget provides a cursor-based single-select option list.

func NewSelectWidget

func NewSelectWidget(wctx *WidgetContext) *SelectWidget

NewSelectWidget creates a single-select option list widget.

func (*SelectWidget) AcceptSubFormResult

func (w *SelectWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; select widgets do not use sub-forms.

func (*SelectWidget) FormatDisplay

func (w *SelectWidget) FormatDisplay() string

FormatDisplay returns a display string for the currently selected option.

func (*SelectWidget) ForwardMsg

func (w *SelectWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; select widgets have no underlying input component.

func (*SelectWidget) Prepare

func (w *SelectWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*SelectWidget) Render

func (w *SelectWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*SelectWidget) Update

func (w *SelectWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*SelectWidget) WidgetContext

func (w *SelectWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type SharedWidgetContext

type SharedWidgetContext struct {
	Schemactx typeschema.EvalContext
	Registry  *config.Registry
	Env       *config.Environment
	FromEnv   *config.Environment
}

SharedWidgetContext provides shared resources to widgets.

type Spec

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

Spec is the command specification for the prompt command.

func (*Spec) Exec

func (s *Spec) Exec(ctx context.Context, cli commands.CLI) error

Exec executes the prompt command.

func (*Spec) Name

func (s *Spec) Name() string

Name returns the name of the command.

func (*Spec) Requirements

func (s *Spec) Requirements(context.Context, commands.CLI) any

Requirements returns the requirements of the command.

type SubFormListWidget

type SubFormListWidget struct {
	SubFormRequest *SubFormRequest
	// contains filtered or unexported fields
}

SubFormListWidget manages a list of complex items (objects, nested lists/maps, etc.) where each item is edited via a nested sub-form.

func (*SubFormListWidget) AcceptSubFormResult

func (w *SubFormListWidget) AcceptSubFormResult(result SubFormResult) bool

AcceptSubFormResult integrates a completed sub-form result into the list.

func (*SubFormListWidget) FormatDisplay

func (w *SubFormListWidget) FormatDisplay() string

FormatDisplay returns a compact summary of the current list value. FormatDisplay may be called before Prepare(), so read from wctx.Value directly rather than the widget's edit buffer.

func (*SubFormListWidget) ForwardMsg

func (w *SubFormListWidget) ForwardMsg(tea.Msg) tea.Cmd

ForwardMsg is a no-op; sub-form lists do not embed a text input.

func (*SubFormListWidget) Prepare

func (w *SubFormListWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*SubFormListWidget) Render

func (w *SubFormListWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*SubFormListWidget) Update

func (w *SubFormListWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*SubFormListWidget) WidgetContext

func (w *SubFormListWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type SubFormMapWidget

type SubFormMapWidget struct {
	SubFormRequest *SubFormRequest
	// contains filtered or unexported fields
}

SubFormMapWidget manages a map with complex values (objects, nested lists/maps, etc.) where each value is edited via a nested sub-form. Keys are entered inline.

func (*SubFormMapWidget) AcceptSubFormResult

func (w *SubFormMapWidget) AcceptSubFormResult(result SubFormResult) bool

AcceptSubFormResult integrates a completed sub-form result into the map.

func (*SubFormMapWidget) FormatDisplay

func (w *SubFormMapWidget) FormatDisplay() string

FormatDisplay returns a compact summary of the current map value. FormatDisplay may be called before Prepare(), so read from wctx.Value directly rather than the widget's edit buffer.

func (*SubFormMapWidget) ForwardMsg

func (w *SubFormMapWidget) ForwardMsg(msg tea.Msg) tea.Cmd

ForwardMsg forwards a bubbletea message to the underlying text input.

func (*SubFormMapWidget) Prepare

func (w *SubFormMapWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*SubFormMapWidget) Render

func (w *SubFormMapWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*SubFormMapWidget) Update

func (w *SubFormMapWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*SubFormMapWidget) WidgetContext

func (w *SubFormMapWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type SubFormRequest

type SubFormRequest struct {
	InputDefs   []*config.InputDefinition // Sub-inputs for the nested form
	InputID     string                    // ID of the parent input being edited
	Title       string                    // Contextual title suffix for the subform (e.g. "Add item 3")
	EditMode    bool                      // true = edit existing values, false = set new
	Values      map[string]cty.Value      // Existing values when EditMode is true
	RefClass    string                    // Non-empty for bundle-ref creation
	SingleInput bool                      // When true, the sub-form hides the bottom panel
}

SubFormRequest carries metadata when a widget signals WidgetNeedSubForm.

type SubFormResult

type SubFormResult struct {
	Values map[string]cty.Value
}

SubFormResult carries the output of a completed sub-form back to its parent widget.

type TextWidget

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

TextWidget wraps a textinput.Model for single-line text inputs. This can be either a string or a number.

func NewTextWidget

func NewTextWidget(wctx *WidgetContext, valueType typeschema.Type) *TextWidget

NewTextWidget creates a single-line text input widget for strings or numbers.

func (*TextWidget) AcceptSubFormResult

func (w *TextWidget) AcceptSubFormResult(SubFormResult) bool

AcceptSubFormResult is a no-op; text widgets do not use sub-forms.

func (*TextWidget) FormatDisplay

func (w *TextWidget) FormatDisplay() string

FormatDisplay returns a display string for the current value.

func (*TextWidget) ForwardMsg

func (w *TextWidget) ForwardMsg(msg tea.Msg) tea.Cmd

ForwardMsg forwards a bubbletea message to the underlying text input.

func (*TextWidget) Prepare

func (w *TextWidget) Prepare()

Prepare initializes the widget for a new editing session.

func (*TextWidget) Render

func (w *TextWidget) Render() []string

Render returns the rendered display lines for the widget.

func (*TextWidget) Update

func (w *TextWidget) Update(msg tea.KeyMsg) (WidgetSignal, tea.Cmd)

Update handles keyboard input and returns the resulting signal.

func (*TextWidget) WidgetContext

func (w *TextWidget) WidgetContext() *WidgetContext

WidgetContext returns the widget's context.

type ViewState

type ViewState int

ViewState represents which view is currently active.

const (
	ViewCloudLogin      ViewState = iota // Cloud login prompt (shown first)
	ViewEnvSelect                        // Unused, kept to preserve iota values
	ViewOverview                         // Main overview
	ViewCreateSelect                     // Flat bundle selection (pre-inputs)
	ViewCreateEnvSelect                  // Environment selection after bundle pick (Create only)
	ViewCreateInput                      // Create-bundle wizard flow (inputs page)
	ViewReconfigSelect                   // Selecting an existing bundle to reconfigure
	ViewReconfigInput                    // Editing the selected existing bundle's inputs
	ViewPromoteSelect                    // Selecting a bundle to promote
	ViewPromoteInput                     // Editing promoted bundle's inputs
)

ViewCloudLogin and the following constants enumerate the possible view states.

type WidgetContext

type WidgetContext struct {
	*SharedWidgetContext
	Width int
	Def   *config.InputDefinition
	Value cty.Value
}

WidgetContext provides per-input context including the shared resources, display width, and current value.

func (*WidgetContext) UpdateValue

func (ctx *WidgetContext) UpdateValue(val cty.Value)

UpdateValue writes val into the WidgetContext and syncs it to the eval context so that cross-input references see the new value.

type WidgetSignal

type WidgetSignal int

WidgetSignal communicates intent from a widget back to InputsForm.

const (
	WidgetContinue    WidgetSignal = iota // Normal operation, keep editing
	WidgetConfirmed                       // Value accepted, advance to next input
	WidgetBack                            // User pressed Esc/ShiftTab, go back
	WidgetNeedSubForm                     // Container needs to open a nested form
)

WidgetContinue and the following constants define the signals a widget can return.

Jump to

Keyboard shortcuts

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