tui

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(composer runner.Composer, logWriter io.Writer, factory ComposerFactory, servers []config.Server, connectCb ConnectCallback, opts ...Option) error

Run launches the TUI.

Types

type ComposerFactory

type ComposerFactory func(projectDir string) runner.Composer

ComposerFactory creates a runner.Composer for the given project directory.

type ConfigProvider

type ConfigProvider interface {
	ConfigFile(ctx context.Context) ([]byte, error)
	ConfigResolved(ctx context.Context) ([]byte, error)
	EditCommand(ctx context.Context) (*exec.Cmd, error)
	ValidateConfig(ctx context.Context) error
}

ConfigProvider provides access to docker-compose configuration files. Defined in the tui package (not runner) because it returns *exec.Cmd and is TUI-only. Both Compose and RemoteCompose implement it.

type ConnectCallback

type ConnectCallback func(server config.Server) (connectCmd *exec.Cmd, factory ComposerFactory, loader ProjectLoader, disconnect func() error)

ConnectCallback is called when a remote server is selected. It returns the SSH connect command (for tea.ExecProcess), a ComposerFactory, a ProjectLoader, and a disconnect function.

type ExecProvider

type ExecProvider interface {
	ExecCommand(ctx context.Context, service string, command []string) (*exec.Cmd, error)
}

ExecProvider provides interactive exec into a container. Defined in the tui package (like ConfigProvider) because it returns *exec.Cmd and is TUI/CLI-only — not a pipeline operation. Both Compose and RemoteCompose implement it.

type Model

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

Model is the Bubble Tea model for the cdeploy TUI.

func NewModel

func NewModel(composer runner.Composer, logWriter io.Writer, factory ComposerFactory, servers []config.Server, connectCb ConnectCallback, opts ...Option) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type Option

type Option func(*Model)

NewModel creates a new TUI model.

Decision table for starting screen:

servers!=nil               -> screenSelectServer  (always show picker)
servers=nil + composer=nil -> screenSelectProject
servers=nil + composer!=nil -> screenSelectContainers

Option configures optional Model behavior.

func WithConfig

func WithConfig(cfg *config.Config) Option

WithConfig sets the live Config used by the settings editor for CRUD operations.

func WithConfigPath

func WithConfigPath(path string) Option

WithConfigPath sets the file path used by the settings editor to save config changes.

func WithLocalProjectLoader

func WithLocalProjectLoader(loader ProjectLoader) Option

WithLocalProjectLoader sets the project loader used for local project discovery. This replaces the default compose.ListProjects fallback with a loader that respects standalone docker-compose detection.

func WithPreselectedServer

func WithPreselectedServer(idx int) Option

WithPreselectedServer makes the TUI skip the server picker and auto-connect to the server at the given index. The index refers to the servers slice passed to NewModel.

type ProjectLoader

type ProjectLoader func(ctx context.Context) ([]compose.Project, error)

ProjectLoader loads the list of projects (local or remote).

Jump to

Keyboard shortcuts

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