tui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package tui is Stampede's interactive terminal UI: slash commands, plain language requests turned into commands, and live run views.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplayScenario

func ReplayScenario(file, base string, speed float64) (*scenario.Scenario, error)

ReplayScenario builds a scenario that replays a recording against base.

func Run

func Run(c *client.Client, opts Options) error

Run starts the program on the terminal.

func Sparkline

func Sparkline(v []float64, width int) string

Sparkline draws the last width values as block characters.

Types

type Command

type Command struct {
	Name string
	Args []string
	// Flags hold --key value pairs.
	Flags map[string]string
}

Command is a parsed slash command.

func Interpret

func Interpret(text string, scenarios []string) (Command, bool)

Interpret turns a plain-language request into a command. It is deliberately simple and always shows the result for confirmation; it never guesses at anything it cannot name.

func ParseSlash

func ParseSlash(line string) (Command, bool)

ParseSlash parses "/run spike checkout --rate 100/s".

func (Command) String

func (c Command) String() string

String renders the command as the user would type it.

type Model

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

Model is the Bubble Tea model.

func New

func New(c *client.Client, opts Options) *Model

New builds the model. c may be nil, in which case /run works on local scenario files with the in-process engine.

func (*Model) Init

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

Init loads the header and scenario names.

func (*Model) Update

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

Update handles input and background messages.

func (*Model) View

func (m *Model) View() string

View renders the screen.

type Options

type Options struct {
	// Init is stampede init with the confirmation already given: it
	// detects the target's product type, installs the matching pack into
	// dir and dry-runs it, writing its progress to w.
	Init func(ctx context.Context, w io.Writer, target, dir string, env []string) error
	// CheckTarget applies stampede run's safety rules to a local run of
	// s and returns the host policy its requests must pass. Messages go
	// to w. Nil leaves local runs without a host policy.
	CheckTarget func(ctx context.Context, w io.Writer, s *scenario.Scenario, env map[string]string) (func(*url.URL) bool, error)
}

Options connect the console to commands that live in the CLI.

Jump to

Keyboard shortcuts

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