wizard

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockUI

type MockUI struct {
	Calls           []string
	ReturnError     error
	WelcomeShown    bool
	CompletionShown bool
	// contains filtered or unexported fields
}

func NewMockUI

func NewMockUI() *MockUI

func (*MockUI) CallCount

func (m *MockUI) CallCount(method string) int

func (*MockUI) ClearCalls

func (m *MockUI) ClearCalls()

func (*MockUI) GetCalls

func (m *MockUI) GetCalls() []string

func (*MockUI) RecordCall

func (m *MockUI) RecordCall(method string)

func (*MockUI) ShowCompletion

func (m *MockUI) ShowCompletion() error

func (*MockUI) ShowStepProgress

func (m *MockUI) ShowStepProgress(_ context.Context, current, total int, stepName string) error

func (*MockUI) ShowStepRetrying

func (m *MockUI) ShowStepRetrying(_ context.Context, stepName string) error

func (*MockUI) ShowStepSkipped

func (m *MockUI) ShowStepSkipped(_ context.Context, stepName string) error

func (*MockUI) ShowWelcome

func (m *MockUI) ShowWelcome() error

func (*MockUI) VerifyCalls

func (m *MockUI) VerifyCalls(expected []string) bool

func (*MockUI) WasCalled

func (m *MockUI) WasCalled(method string) bool

type PTermUI

type PTermUI struct {
	WelcomeText    string
	CompletionText string
}

func NewPTermUI

func NewPTermUI(welcomeText, completionText string) *PTermUI

func (*PTermUI) ShowCompletion

func (p *PTermUI) ShowCompletion() error

func (*PTermUI) ShowStepProgress

func (p *PTermUI) ShowStepProgress(_ context.Context, current, total int, stepName string) error

func (*PTermUI) ShowStepRetrying

func (p *PTermUI) ShowStepRetrying(_ context.Context, stepName string) error

func (*PTermUI) ShowStepSkipped

func (p *PTermUI) ShowStepSkipped(_ context.Context, stepName string) error

func (*PTermUI) ShowWelcome

func (p *PTermUI) ShowWelcome() error

type Result

type Result struct {
	StepsCompleted int
	StepsSkipped   int
	StepsRetried   int
	StepsTotal     int
	Completed      bool
}

func Run

func Run[S any](ctx context.Context, ui UI, steps []Step[S], state S) (Result, error)

type Step

type Step[S any] interface {
	Name() string
	ShouldSkip(state S) bool
	Execute(ctx context.Context, state S) error
	ShouldRetry(state S) bool
}

type StepFunc

type StepFunc[S any] struct {
	Name_       string
	SkipFunc    func(state S) bool
	ExecuteFunc func(ctx context.Context, state S) error
	RetryFunc   func(state S) bool
}

func (StepFunc[S]) Execute

func (sf StepFunc[S]) Execute(ctx context.Context, state S) error

func (StepFunc[S]) Name

func (sf StepFunc[S]) Name() string

func (StepFunc[S]) ShouldRetry

func (sf StepFunc[S]) ShouldRetry(state S) bool

func (StepFunc[S]) ShouldSkip

func (sf StepFunc[S]) ShouldSkip(state S) bool

type UI

type UI interface {
	ShowWelcome() error
	ShowStepProgress(ctx context.Context, current, total int, stepName string) error
	ShowStepSkipped(ctx context.Context, stepName string) error
	ShowStepRetrying(ctx context.Context, stepName string) error
	ShowCompletion() error
}

Jump to

Keyboard shortcuts

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