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:
- Welcome — ASCII art logo + "press enter to begin"
- Project Info — project name + Go module path
- Protocols — multi-select protocol adapters
- Database — single-select database backend
- Auth — single-select authentication strategy
- Middleware — multi-select middleware pipeline
- Infrastructure — multi-select Docker, CI, K8s options
- Review — summary of all selections
- 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 ¶
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) Complete ¶
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).
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. |