dbwizard

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dbwizard is the interactive picker that runs when `maestro service <name>` is called. It captures the database choice (engine + mode) for the new service and, for a live database, verifies the supplied URL with a real ping before letting generation continue.

Index

Constants

This section is empty.

Variables

View Source
var ErrBack = errors.New("dbwizard: back to caller")

ErrBack is returned when the user pressed esc at the wizard's starting step on a flow that hid earlier steps via pre-filled fields. There's nowhere to navigate back to inside this program, so the orchestrating caller is expected to re-open whatever TUI ran before — typically with the previous answers pre-filled so the user can adjust them.

View Source
var ErrCancelled = errors.New("dbwizard: cancelled")

ErrCancelled is returned by RunWizard when the user aborts with ctrl+c.

Functions

This section is empty.

Types

type Result

type Result struct {
	Shape     config.ServiceShape
	DB        config.DBEngine
	DBMode    config.DBMode
	Port      int
	WantRedis bool
	RedisMode config.RedisMode
}

Result is the captured choice. WantRedis is an input flag (the preset's main service declares a Redis dependency); RedisMode is the captured docker/live answer for it.

func RunWizard

func RunWizard(serviceName string, existing map[string]config.ServiceConfig, initial Result) (Result, error)

RunWizard opens the TUI for serviceName and returns the user's choice. existing is the project's currently-registered services from project.toml — the wizard uses it to compute a default port that doesn't collide.

initial lets the caller pre-fill answers and skip the corresponding steps: a preset that knows its service must be HTTP can pin Result{Shape: ShapeHTTP} and the user never sees the shape picker. Pre-filled answers are also un-walkable via esc — the wizard refuses to navigate back past startStep so users can't fall into a screen we deliberately hid.

A ctrl+c cancel surfaces as ErrCancelled so the caller can abort generation.

func RunWizardResumeAtMode

func RunWizardResumeAtMode(serviceName string, existing map[string]config.ServiceConfig, prior Result) (Result, error)

RunWizardResumeAtMode re-opens the wizard at the docker-vs-live mode picker with prior pre-filled and the cursor on the previously chosen mode. Used by the preset flow when a downstream TUI signals "back": the engine is pinned by the manifest, so the natural in-wizard landmark to return to is the mode question, not an engine picker that flow never showed.

startStep is recomputed as if only Shape were pinned, so esc from stepMode walks back to stepPort and then bubbles up via ErrBack — the chain matches the user's original path forward through the wizard.

Jump to

Keyboard shortcuts

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