Documentation
¶
Overview ¶
Package tui is sdd's bubble tea layer: the transient coordinator display for long-running commands (Interactive, which lets a cliout.Coordinator own the dormant → armed → live → done lifecycle so instant work never starts a program) and the reusable init input prompts (text, select, multi-select, confirm). Both surfaces route through the one shared program runner (runner.go). It depends on the bubble-tea-free core in internal/cliout; only cmd/sdd imports this package.
Index ¶
- Variables
- func Interactive[T any](ctx context.Context, policy cliout.Policy, view View, ...) (T, error)
- func RunConfirm(cfg ConfirmPrompt) (bool, error)
- func RunMultiSelect[T any](cfg MultiSelectPrompt[T]) ([]T, error)
- func RunSelect[T any](cfg SelectPrompt[T]) (T, error)
- func RunTextPrompt(cfg TextPrompt) (string, error)
- type ConfirmPrompt
- type MultiSelectOption
- type MultiSelectPrompt
- type SelectOption
- type SelectPrompt
- type TextPrompt
- type View
Constants ¶
This section is empty.
Variables ¶
var ErrPromptCancelled = errors.New("prompt cancelled")
ErrPromptCancelled is returned when the user aborts a prompt (ctrl+c / esc) instead of confirming a value.
Functions ¶
func Interactive ¶
func Interactive[T any](ctx context.Context, policy cliout.Policy, view View, work func(context.Context) (T, error)) (T, error)
Interactive runs work under a transient terminal view governed by policy, returning work's result. It is the single reusable coordinator entry for any long-running command — index, search lazy-fill, repo add, and future bulk operations. The caller has already established this is a TTY; off-TTY paths never reach here and keep plain slog on stderr.
func RunConfirm ¶ added in v0.17.0
func RunConfirm(cfg ConfirmPrompt) (bool, error)
RunConfirm runs the confirmation prompt on a TTY. Aborting (ctrl+c / esc) or empty input yields false without an error — the safe "leave it alone" side.
func RunMultiSelect ¶ added in v0.17.0
func RunMultiSelect[T any](cfg MultiSelectPrompt[T]) ([]T, error)
RunMultiSelect runs the multi-select prompt on a TTY, returning the selected options' values in option order, or ErrPromptCancelled if aborted.
func RunSelect ¶ added in v0.17.0
func RunSelect[T any](cfg SelectPrompt[T]) (T, error)
RunSelect runs the single-select prompt on a TTY, returning the chosen option's value or ErrPromptCancelled if the user aborts.
func RunTextPrompt ¶ added in v0.17.0
func RunTextPrompt(cfg TextPrompt) (string, error)
RunTextPrompt runs the text prompt on a TTY, returning the entered value (Default on empty input) or ErrPromptCancelled if the user aborts.
Types ¶
type ConfirmPrompt ¶ added in v0.17.0
type ConfirmPrompt struct {
Prompt string
}
ConfirmPrompt configures a single-char y/N confirmation.
type MultiSelectOption ¶ added in v0.17.0
MultiSelectOption is one row of a multi-select prompt, carrying the domain value it stands for and its initial checked state.
type MultiSelectPrompt ¶ added in v0.17.0
type MultiSelectPrompt[T any] struct { Header string Options []MultiSelectOption[T] }
MultiSelectPrompt configures a cursor-navigated multi-select toggled with space; enter confirms only once at least one option is selected.
type SelectOption ¶ added in v0.17.0
SelectOption is one row of a single- or multi-select prompt. Value is the domain value the option stands for, returned when the option is chosen.
type SelectPrompt ¶ added in v0.17.0
type SelectPrompt[T any] struct { Header string Options []SelectOption[T] Cursor int }
SelectPrompt configures a cursor-navigated single-select. Header is printed on its own line above the options; Cursor is the initial selection.
type TextPrompt ¶ added in v0.17.0
TextPrompt configures a single-line text-input prompt. The rendered line is "<Label> [<Default>]: <input>"; empty input returns Default.
type View ¶
type View struct {
// InitialPhase is the footer label shown until the work reports its first
// phase; from then on the label derives from the reporter's Phase snapshots.
InitialPhase sddmodel.Phase
// Progress carries the phase and count snapshots the footer renders. The
// bar appears in the indexing phase once a total is present; the caller
// advances it via absolute counts (SetTotal/Add) and phase transitions
// (SetPhase). Nil leaves a bare spinner with the InitialPhase label.
Progress *cliout.Reporter
// StreamLogs, when true, emits display-eligible log entries as durable
// lines that scroll into terminal history — the "indexing logs persist"
// case. When false the live view is footer-only and logs stay hidden,
// surfaced only by the teardown re-emit on a warning/error — the "search
// indexing is transient" case.
StreamLogs bool
}
View specs a phase-labeled footer for one operation: an initial phase label, an optional progress reporter (phase + count snapshots), and an opt-in log stream. The footer label tracks the reporter's current phase, so commands never decide a label string mid-run.