Help us shape the future of Go! Take the 2026 Go Developer Survey

formpage

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package formpage runs a wizard's pages so that accessible mode asks what the TUI shows. huh's accessible runner asks every group in turn, never consults a group's hide condition (huh v2.0.3; huh#780) and never evaluates the reactive *Func bindings, and huh exposes no way to read a hide condition back. So a wizard declares its pages here: each visible page runs on its own, built when its turn comes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Groups

func Groups(pages ...Page) []*huh.Group

Groups builds the pages' groups, in order.

func Run

func Run(pages []Page, accessible bool, build func(...*huh.Group) *huh.Form, run func(*huh.Form) error) error

Run runs the pages through build and run. On a terminal they are one form, so back-navigation crosses pages. In accessible mode each visible page is its own form, its hide condition asked and its group built when its turn comes, so the answers on earlier pages decide both.

func ValidateAnswer

func ValidateAnswer(current *string, validate func(string) error) func(string) error

ValidateAnswer validates the answer a text field will keep. At an accessible prompt huh validates the line as typed, so an empty line, which keeps the field's current value, was validated as "" and a required field refused its own pre-filled answer (huh v2.0.3; huh#833). On the TUI path the bound value follows every keystroke, so this changes nothing there.

Types

type Page

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

Page is one group of a wizard and the condition that hides it.

func Deferred

func Deferred(build func() *huh.Group) Page

Deferred is a page built by build. On a terminal every page is built before the form runs, as Of is; in accessible mode it is built when its turn comes, so the text it computes from earlier answers is current.

func Of

func Of(g *huh.Group) Page

Of is a page of a group already built.

func (Page) Group

func (p Page) Group() *huh.Group

Group builds the page's huh group, with its hide condition attached.

func (Page) HiddenWhen

func (p Page) HiddenWhen(hide func() bool) Page

HiddenWhen hides the page while hide reports true, on the TUI path through huh and in accessible mode through Run.

Jump to

Keyboard shortcuts

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