Skip to content

A modular, pluggable wizard orchestrator for TinyGo applications. It manages multi-step workflows with state persistence using tinywasm/context, designed for lightweight CLI and TUI integrations.

License

Notifications You must be signed in to change notification settings

tinywasm/wizard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinywasm/wizard

Project Badges

A modular, pluggable wizard orchestrator for TinyGo applications.

LLM Context / Core Logic

The library orchestrates a sequence of Step struct helpers. It manages state via a mutable tinywasm/context.

Steps

type Step struct {
    LabelText  string
    DefaultFn  func(ctx *context.Context) string
    OnInputFn  func(input string, ctx *context.Context) (continueFlow bool, err error)
}

Flow Control

  • New(onComplete func(ctx *context.Context), modules ...Module): Initializes orchestration.
  • Change(input): Executes OnInput for the current step.
  • If error != nil, the wizard stays on the current step.
  • If error == nil and continueFlow == true, the wizard advances to the next step.

Features

  • Zero dynamic allocations (fixed capacity context).
  • Mutable State: Steps modify the context directly via ctx.Set().
  • Easy Literals: Define steps as simple structs without boilerplate.
  • TUI-ready: Implements Handler and Loggable patterns.

Usage

// 1. Define a Module
type MyModule struct {
    Steps []*wizard.Step
}
func (m MyModule) Name() string { return "My Module" }
func (m MyModule) GetSteps() []any {
    steps := make([]any, len(m.Steps))
    for i, s := range m.Steps {
        steps[i] = s
    }
    return steps
}

// 2. Create steps
steps := []*wizard.Step{
    {
        LabelText: "Project Name",
        DefaultFn: func(ctx *context.Context) string { return "my-app" },
        OnInputFn: func(in string, ctx *context.Context) (bool, error) {
            if in == "" { return false, nil }
            err := ctx.Set("name", in) // Mutate context in-place
            return true, err
        },
    },
}

// 3. Run wizard
wiz := wizard.New(func(ctx *context.Context) { println("Done!") }, &MyModule{Steps: steps})
wiz.Change("new-project")

About

A modular, pluggable wizard orchestrator for TinyGo applications. It manages multi-step workflows with state persistence using tinywasm/context, designed for lightweight CLI and TUI integrations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages