wizard

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 2 Imported by: 0

README

tinywasm/wizard

Project Badges

A modular, pluggable wizard orchestrator for TinyGo applications.

LLM Context / Core Logic

The library orchestrates a sequence of Step interfaces. It manages state via tinywasm/context and handles flow control through a completion callback.

Interfaces
type Step interface {
    Label() string                                                                 // Prompt text
    DefaultValue(ctx *context.Context) string                                     // UI Suggestion
    OnInput(in string, ctx *context.Context) (*context.Context, bool, error)      // Logic + next state
}
Flow Control
  • New(onComplete func(), steps ...Step): Initializes orchestration.
  • Change(input): Executes OnInput for the current step.
  • continueFlow (bool): If true, the wizard proceeds even if error != nil (soft failure). If false, it stays on the same step (hard failure).

Features

  • Zero dynamic allocations (fixed capacity context).
  • Duck-typing compatible: Designed to be implemented by external modules without direct package dependencies.
  • TUI-ready: Implements Handler and Loggable patterns.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module added in v0.0.2

type Module interface {
	// Name returns the module identifier
	Name() string

	// GetSteps returns the sequence of steps this module requires.
	GetSteps() []any
}

Module represents a pluggable component that provides a sequence of steps

type Step added in v0.0.2

type Step interface {
	// Label returns the prompt text for the UI (e.g., "Project Name")
	Label() string

	// DefaultValue returns a suggestion based on the current context
	DefaultValue(ctx *context.Context) string

	// OnInput executes the step logic.
	OnInput(input string, ctx *context.Context) (newCtx *context.Context, continueFlow bool, err error)
}

Step represents a single interaction or execution unit in the wizard

type Wizard

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

Wizard orchestrates the execution of multiple Steps

func New

func New(onComplete func(), steps ...Step) *Wizard

New creates a generic wizard with the given steps

func (*Wizard) AlwaysShowAllLogs added in v0.0.2

func (w *Wizard) AlwaysShowAllLogs() bool

StreamingLoggable implementation

func (*Wizard) Cancel added in v0.0.2

func (w *Wizard) Cancel()

Cancelable implementation

func (*Wizard) Change added in v0.0.2

func (w *Wizard) Change(newValue string)

func (*Wizard) Label added in v0.0.2

func (w *Wizard) Label() string

func (*Wizard) Name added in v0.0.2

func (w *Wizard) Name() string

func (*Wizard) SetLog added in v0.0.2

func (w *Wizard) SetLog(f func(message ...any))

Loggable implementation

func (*Wizard) Value added in v0.0.2

func (w *Wizard) Value() string

func (*Wizard) WaitingForUser added in v0.0.2

func (w *Wizard) WaitingForUser() bool

Jump to

Keyboard shortcuts

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