Documentation
¶
Overview ¶
Package tui is Stampede's interactive terminal UI: slash commands, plain language requests turned into commands, and live run views.
Index ¶
Constants ¶
const ExecArg = "console-exec"
ExecArg is the hidden subcommand that runs a command on the console's behalf with the terminal and waits for Enter before returning to it.
Variables ¶
This section is empty.
Functions ¶
func ReplayScenario ¶
ReplayScenario builds a scenario that replays a recording against base.
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 ¶
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 ¶
ParseSlash parses "/run spike checkout --rate 100/s".
type Kind ¶ added in v1.1.0
type Kind int
Kind says how the console runs a stampede command it has no built-in form of.
const ( // Inline runs the command with its output in the console. Inline Kind = iota // Terminal hands it the terminal: it may ask for a password, or print // something secret (a new token) that must not be kept in the session. Terminal // Daemon commands run until stopped and belong in their own terminal. Daemon )
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubble Tea model.
func New ¶
New builds the model. c may be nil, in which case /run works on local scenario files with the in-process engine.
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)
// Commands are the stampede subcommands the console runs for a /name
// it has no built-in form of, with how to run each; Self is the
// stampede executable they run as.
Commands map[string]Kind
Self string
// Store keeps sessions and the input history; nil keeps nothing.
Store *Store
// Resume is a saved session to continue instead of starting a new one.
Resume *Session
}
Options connect the console to commands that live in the CLI.
type Session ¶ added in v1.1.0
type Session struct {
ID string `json:"id"`
Started time.Time `json:"started"`
Updated time.Time `json:"updated"`
Server string `json:"server,omitempty"`
Project string `json:"project,omitempty"`
// Title is the first thing typed in the session.
Title string `json:"title,omitempty"`
Inputs int `json:"inputs"`
Lines []string `json:"lines"`
}
Session is one console conversation, saved so it can be picked up again with `stampede --continue`, `stampede --resume <id>` or /resume.
type Store ¶ added in v1.1.0
type Store struct {
// contains filtered or unexported fields
}
Store keeps sessions and the input history under the user's config directory (~/.config/stampede/console on Linux), readable only by them.
func OpenStoreAt ¶ added in v1.1.0
OpenStoreAt opens a store in dir.
func (*Store) AddHistory ¶ added in v1.1.0
AddHistory appends a typed line, keeping the last 1000.
func (*Store) History ¶ added in v1.1.0
History returns the lines typed in earlier sessions, oldest first.
func (*Store) List ¶ added in v1.1.0
List returns saved sessions, most recently used first, without their transcripts; n <= 0 returns all.