Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProgram

func NewProgram(ui Model) *tea.Program

NewProgram constructs the tea.Program for the TUI.

Types

type Model

type Model interface {
	RefreshList(ctx context.Context) error
	ListCached() []adapters.CommandSetSummary
	GetCommandSet(ctx context.Context, name string) (adapters.CommandSetSummary, error)
	ListVersions(ctx context.Context, name string) ([]adapters.Version, error)
	ApplyVersion(ctx context.Context, name string, version int) error
	DeleteVersion(ctx context.Context, name string, version int) error
	Delete(ctx context.Context, name string) error
	Export(ctx context.Context, name string, dest string) error
	ImportSet(ctx context.Context, src string, policy string, dedupe bool) error
	ImportDB(ctx context.Context, src string, overwrite bool) error
	// ReopenDB forces the model to re-open the underlying DB connection and
	// refresh its registry adapter. This is necessary after a full DB file
	// overwrite so subsequent queries read the new file contents.
	ReopenDB(ctx context.Context) error
	// Close cleans up any resources held by the model (e.g., DB connections).
	Close() error
	UpdateCommandSet(ctx context.Context, oldName string, cs adapters.CommandSetSummary) error
	ReplaceCommands(ctx context.Context, name string, cmds []string) error
	// UpdateCommandSetAndReplaceCommands performs an atomic metadata+commands update
	// and records a single 'update' version representing the final state.
	UpdateCommandSetAndReplaceCommands(ctx context.Context, oldName string, cs adapters.CommandSetSummary) error
	Run(ctx context.Context, name string, _ []string) (adapters.RunHandle, error)
	Save(ctx context.Context, cs adapters.CommandSetSummary) error
	Install(ctx context.Context, opts install.Options) ([]string, error)
	Uninstall(ctx context.Context) ([]string, error)
}

Model defines the small subset of methods from the framework-agnostic internal UI model that the TUI depends on. This decouples presentation code from the concrete implementation and makes unit testing easier.

Named `Model` (instead of `UIModel`) to avoid redundant package/type stuttering when referenced as `ui.Model`.

type TuiModel

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

TuiModel is the Bubble Tea model used by cmd/tui.

func NewModel

func NewModel(ui Model) *TuiModel

NewModel constructs the Bubble Tea TUI model used by cmd/tui. It accepts any implementation of Model (usually the framework-agnostic internal model) so tests can provide fakes.

func (*TuiModel) Init

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

Init initializes the model by refreshing the list and populating the preview.

func (*TuiModel) IsDetailShown

func (m *TuiModel) IsDetailShown() (bool, string)

IsDetailShown reports detail visibility and the currently shown name (thread-safe).

func (*TuiModel) Update

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

Update handles incoming events and updates model state.

func (*TuiModel) View

func (m *TuiModel) View() string

View renders the current TUI view as a string.

Jump to

Keyboard shortcuts

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