tui

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package tui provides the visual foundation for the Nexus CLI's interactive terminal user interface.

This file implements the multi-step init wizard — a bubbletea model that chains together all wizard screens into a linear flow with back navigation. The wizard manages a state machine with the following steps:

  1. Welcome — ASCII art logo + "press enter to begin"
  2. Project Info — project name + Go module path
  3. Protocols — multi-select protocol adapters
  4. Database — single-select database backend
  5. Auth — single-select authentication strategy
  6. Middleware — multi-select middleware pipeline
  7. Infrastructure — multi-select Docker, CI, K8s options
  8. Review — summary of all selections
  9. Generating — progress display during code generation

The wizard accumulates user choices into a generator.ProjectConfig struct that is available once the review step is confirmed. Back navigation via Esc is supported on all screens except the welcome screen and the generating screen. Ctrl+C cancels the wizard at any point with a clean exit.

The wizard does NOT perform code generation itself — it emits a WizardCompleteMsg containing the final ProjectConfig, and the caller (internal/cli/init.go) is responsible for passing it to the generator engine.

Usage:

w := tui.NewWizard("")
p := tea.NewProgram(w, tea.WithAltScreen())
model, err := p.Run()
if err != nil { ... }
wiz := model.(tui.Wizard)
if wiz.Cancelled() { os.Exit(0) }
cfg := wiz.Config()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Wizard

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

Wizard is the top-level bubbletea model that manages the init wizard's multi-step flow. It holds all screen models and the accumulating ProjectConfig, and routes messages to the active screen based on the current step.

func NewWizard

func NewWizard(initialName string) Wizard

NewWizard creates a new Wizard model. If initialName is non-empty, it is pre-filled into the project name field on the project info screen. The wizard starts on the welcome screen.

func (Wizard) Cancelled

func (m Wizard) Cancelled() bool

Cancelled returns whether the user cancelled the wizard with Ctrl+C.

func (Wizard) Complete

func (m Wizard) Complete() bool

Complete returns whether the wizard finished successfully (user confirmed the review screen).

func (Wizard) Config

func (m Wizard) Config() generator.ProjectConfig

Config returns the accumulated ProjectConfig. This is only meaningful after the wizard completes (Complete() returns true).

func (Wizard) Init

func (m Wizard) Init() tea.Cmd

Init returns the initial command for the welcome screen's blink animation.

func (Wizard) Step

func (m Wizard) Step() int

Step returns the current wizard step. Useful for testing and debugging.

func (Wizard) Update

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

Update is the central message router for the wizard. It handles global keys (Ctrl+C, Esc), routes screen-specific messages to the active screen, and manages step transitions when screens emit their "done" messages.

func (Wizard) View

func (m Wizard) View() string

View renders the active screen. Only the current step's screen is rendered — previous screens are not visible.

type WizardCancelledMsg

type WizardCancelledMsg struct{}

WizardCancelledMsg is sent when the user cancels the wizard with Ctrl+C.

type WizardCompleteMsg

type WizardCompleteMsg struct {
	// Config is the fully populated ProjectConfig containing all user
	// selections from the wizard.
	Config generator.ProjectConfig
}

WizardCompleteMsg is sent when the wizard finishes successfully (the user confirms the review screen). The parent program should handle this to retrieve the ProjectConfig and start code generation.

Directories

Path Synopsis
Package components provides reusable bubbletea TUI components for the Nexus CLI's interactive wizards.
Package components provides reusable bubbletea TUI components for the Nexus CLI's interactive wizards.
Package screens provides the individual TUI screens used in the Nexus CLI's interactive wizards.
Package screens provides the individual TUI screens used in the Nexus CLI's interactive wizards.
Package theme provides the centralized color palette, reusable lipgloss styles, and the ASCII art logo used throughout every TUI screen and component.
Package theme provides the centralized color palette, reusable lipgloss styles, and the ASCII art logo used throughout every TUI screen and component.

Jump to

Keyboard shortcuts

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