wizard

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wizard is otag's setup wizard (`otag init`, bare `otag` on a fresh machine, and the confirm step of `otag project add`): a short sequence of form pages built with the TUI's dialog kit (internal/tui/form) and theme. The model is pure: the detection results and the current choices come in through Options, and the only side effects (preview and apply) are functions there, so it is tested without a terminal or any file writes. Nothing is written before the Review page's Write.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode int

Mode selects the pages.

const (
	// Init is the whole setup: detect, agents, profiles, project, daemon, skill, review.
	Init Mode = iota
	// Project is `otag project add` on a terminal: the project page and the review.
	Project
)

Modes.

type Model

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

Model is the wizard's Bubble Tea model.

func New

func New(ctx context.Context, o Options) *Model

New returns the wizard on its first page.

func (*Model) Init

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

Init implements tea.Model.

func (*Model) Result

func (m *Model) Result() Result

Result is the outcome once the program ended.

func (*Model) Update

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

Update implements tea.Model.

func (*Model) View

func (m *Model) View() tea.View

View implements tea.Model.

type Options

type Options struct {
	Mode    Mode
	Base    setup.Base
	Choices setup.Choices // the proposals (setup.Base.Defaults)
	// Preview computes the Review page for the current choices (no writes).
	Preview func(c setup.Choices) Preview
	// Apply writes the files and runs sync, daemon and skill install as chosen.
	Apply func(ctx context.Context, c setup.Choices) (Report, error)
	// Offer the TUI at the end (Init mode).
	OfferTUI bool
}

Options configure the wizard.

type Preview

type Preview struct {
	Files    []setup.File
	Warnings []string
	Err      string
}

Preview is what the Review page shows: the files that would be written and the warnings the result would load with (Err: it would not load, Write is refused).

type Report

type Report struct {
	Lines    []string
	Warnings []string
}

Report is what Apply did, one line per step, and its warnings.

type Result

type Result struct {
	Applied bool          `json:"applied"`
	OpenTUI bool          `json:"open_tui"`
	Choices setup.Choices `json:"choices"`
	Report  Report        `json:"report"`
	Err     string        `json:"error,omitempty"`
}

Result is how the wizard ended.

func Run

func Run(ctx context.Context, o Options) (Result, error)

Run shows the wizard until it ends and returns how it ended. A cancelled parent context (ctrl+c outside the program) ends it like Cancel.

Jump to

Keyboard shortcuts

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