Documentation
¶
Overview ¶
Package forms provides reusable helpers for building multi-step interactive CLI forms on top of charmbracelet/huh. It adds Escape- to-go-back navigation and a step runner that interprets abort signals as back navigation.
All navigable forms render in the alternate screen buffer so that each step gets a clean display and leaves no residual output in the terminal or scrollback when it completes or is aborted.
Escape returns to the previous step (or cancels if on the first step). Ctrl+C sends SIGINT which terminates the process immediately.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNavigable ¶
NewNavigable creates a huh.Form with Escape bound to Quit and rendering in the alternate screen buffer. Each form gets a clean display and leaves no residual output when it completes or is aborted. Pressing Escape causes Run() to return huh.ErrUserAborted, which a Wizard interprets as "go back one step".
func RunStepsWithBack ¶
RunStepsWithBack executes a sequence of form step functions with back-navigation support. Prefer Wizard for new code; this function is retained for backward compatibility.
Types ¶
type Wizard ¶
type Wizard struct {
// contains filtered or unexported fields
}
Wizard manages a multi-step interactive form flow with Escape-to-go-back navigation. Each step is either a static set of huh.Groups displayed as a single navigable form, or a custom function for dynamic logic.
Build with NewWizard, optionally extend with Group/Step, then call Run.
func NewWizard ¶
NewWizard creates a Wizard whose initial steps are the given groups — each group becomes one navigable form step. For a purely static multi-step flow this is all you need:
err := forms.NewWizard(groupA, groupB, groupC).Run()
For mixed flows, chain Group and Step after the constructor.
func (*Wizard) Group ¶
Group adds a step that displays one or more huh groups as a single navigable form. Use this for static form content that doesn't depend on earlier steps.