Documentation
¶
Overview ¶
Package formtest drives real huh forms in tests with no TTY and no production seam (spec 0198 D3). Answers feeds accessible-mode prompts one line per field; Keys feeds the TUI path one key sequence at a time.
Both rest on a reader that yields one chunk per Read: accessible mode reads each field through a fresh buffered reader, so a single reader holding every answer loses all but the first, and the TUI's key parser merges bytes that arrive in one read.
Index ¶
Constants ¶
const ( Enter = "\r" Down = "\x1b[B" Up = "\x1b[A" Space = " " Tab = "\t" Yes = "y" No = "n" )
Key sequences for Keys, named for what a person presses.
Variables ¶
This section is empty.
Functions ¶
func AccessibleTTY ¶
AccessibleTTY is an IO for a terminal in accessible mode (a screen reader, or TERM=dumb): interactive, so a prompt that is gated on a terminal is reached, and accessible, so it takes Answers. Parallel-safe, unlike the key route.
func Answers ¶
Answers is what a person types at accessible-mode prompts, one per field: an option's number for a select, a line for an input, y or n for a confirm. Pair it with an IO whose Accessible reports true.
func Keys ¶
Keys is what a person presses on the TUI path, one sequence per Read, paced so the parser sees each on its own and a field change has happened before the next key. Typed text is one key per rune. The pacing is time, so a test on this route does not call t.Parallel: contention is what makes a paced key land early.
func ProgramOptions ¶
func ProgramOptions(in io.Reader) []tea.ProgramOption
ProgramOptions are the bubbletea options a form on the key route needs: the keys as input, no output, no renderer, a terminal the parser recognises, and a window size, since no renderer means no WindowSizeMsg and a field with a placeholder panics on a negative width.
func TUI ¶
TUI is an IO for the key route: interactive as far as the form is concerned, with the program running headless. The form's own WithProgramOptions receive ProgramOptions.
func TUIForms ¶
TUIForms is TUI for a wizard that runs several forms in turn: each In() hands the next script to the next form. A form's program reads its input ahead of the keys it has handled and does not give the surplus back when the form completes, so a later form's keys left on a shared reader are lost with the program that read them. One script per form, in the order the forms run; a form past the last script reads nothing.
Types ¶
This section is empty.