Documentation
¶
Index ¶
- type Confirm
- func (c *Confirm) Accessor(a huh.Accessor[bool]) *Confirm
- func (c *Confirm) Affirmative(s string) *Confirm
- func (c *Confirm) Description(s string) *Confirm
- func (c *Confirm) DescriptionFunc(f func() string, bindings any) *Confirm
- func (c *Confirm) Inline(inline bool) *Confirm
- func (c *Confirm) Key(k string) *Confirm
- func (c *Confirm) Negative(s string) *Confirm
- func (c *Confirm) Optional() *Confirm
- func (c *Confirm) Title(s string) *Confirm
- func (c *Confirm) TitleFunc(f func() string, bindings any) *Confirm
- func (c *Confirm) Validate(fn func(bool) error) *Confirm
- func (c *Confirm) Value(v *bool) *Confirm
- func (c *Confirm) WithButtonAlignment(p lipgloss.Position) *Confirm
- type Form
- type Group
- func (g *Group) Description(s string) *Group
- func (g *Group) Title(s string) *Group
- func (g *Group) WithHeight(h int) *Group
- func (g *Group) WithHide(hide bool) *Group
- func (g *Group) WithHideFunc(fn func() bool) *Group
- func (g *Group) WithKeyMap(k *huh.KeyMap) *Group
- func (g *Group) WithShowErrors(show bool) *Group
- func (g *Group) WithShowHelp(show bool) *Group
- func (g *Group) WithTheme(t huh.Theme) *Group
- func (g *Group) WithWidth(w int) *Group
- type Input
- func (i *Input) Accessor(a huh.Accessor[string]) *Input
- func (i *Input) CharLimit(n int) *Input
- func (i *Input) Description(s string) *Input
- func (i *Input) DescriptionFunc(f func() string, bindings any) *Input
- func (i *Input) EchoMode(mode huh.EchoMode) *Input
- func (i *Input) Inline(inline bool) *Input
- func (i *Input) Key(k string) *Input
- func (i *Input) Optional() *Input
- func (i *Input) Password(password bool) *Input
- func (i *Input) Placeholder(s string) *Input
- func (i *Input) PlaceholderFunc(f func() string, bindings any) *Input
- func (i *Input) Prompt(s string) *Input
- func (i *Input) Suggestions(suggestions []string) *Input
- func (i *Input) SuggestionsFunc(f func() []string, bindings any) *Input
- func (i *Input) Title(s string) *Input
- func (i *Input) TitleFunc(f func() string, bindings any) *Input
- func (i *Input) Validate(fn func(string) error) *Input
- func (i *Input) Value(v *string) *Input
- type Mode
- type MultiSelect
- func (m *MultiSelect[T]) Accessor(a huh.Accessor[[]T]) *MultiSelect[T]
- func (m *MultiSelect[T]) Description(d string) *MultiSelect[T]
- func (m *MultiSelect[T]) DescriptionFunc(f func() string, bindings any) *MultiSelect[T]
- func (m *MultiSelect[T]) Filterable(filterable bool) *MultiSelect[T]
- func (m *MultiSelect[T]) Filtering(filtering bool) *MultiSelect[T]
- func (m *MultiSelect[T]) Height(h int) *MultiSelect[T]
- func (m *MultiSelect[T]) Key(k string) *MultiSelect[T]
- func (m *MultiSelect[T]) Limit(n int) *MultiSelect[T]
- func (m *MultiSelect[T]) Optional() *MultiSelect[T]
- func (m *MultiSelect[T]) Options(opts ...huh.Option[T]) *MultiSelect[T]
- func (m *MultiSelect[T]) OptionsFunc(f func() []huh.Option[T], bindings any) *MultiSelect[T]
- func (m *MultiSelect[T]) Title(t string) *MultiSelect[T]
- func (m *MultiSelect[T]) TitleFunc(f func() string, bindings any) *MultiSelect[T]
- func (m *MultiSelect[T]) Validate(fn func([]T) error) *MultiSelect[T]
- func (m *MultiSelect[T]) Value(v *[]T) *MultiSelect[T]
- func (m *MultiSelect[T]) Width(w int) *MultiSelect[T]
- type Option
- type Runner
- type Select
- func (s *Select[T]) Accessor(a huh.Accessor[T]) *Select[T]
- func (s *Select[T]) Description(d string) *Select[T]
- func (s *Select[T]) DescriptionFunc(f func() string, bindings any) *Select[T]
- func (s *Select[T]) Filtering(filtering bool) *Select[T]
- func (s *Select[T]) Height(height int) *Select[T]
- func (s *Select[T]) Inline(inline bool) *Select[T]
- func (s *Select[T]) Key(k string) *Select[T]
- func (s *Select[T]) Optional() *Select[T]
- func (s *Select[T]) Options(opts ...huh.Option[T]) *Select[T]
- func (s *Select[T]) OptionsFunc(f func() []huh.Option[T], bindings any) *Select[T]
- func (s *Select[T]) Title(t string) *Select[T]
- func (s *Select[T]) TitleFunc(f func() string, bindings any) *Select[T]
- func (s *Select[T]) Validate(fn func(T) error) *Select[T]
- func (s *Select[T]) Value(v *T) *Select[T]
- type Text
- func (t *Text) Accessor(a huh.Accessor[string]) *Text
- func (t *Text) CharLimit(n int) *Text
- func (t *Text) Description(s string) *Text
- func (t *Text) DescriptionFunc(f func() string, bindings any) *Text
- func (t *Text) Editor(editor ...string) *Text
- func (t *Text) EditorExtension(ext string) *Text
- func (t *Text) ExternalEditor(enabled bool) *Text
- func (t *Text) Key(k string) *Text
- func (t *Text) Lines(n int) *Text
- func (t *Text) Optional() *Text
- func (t *Text) Placeholder(s string) *Text
- func (t *Text) PlaceholderFunc(f func() string, bindings any) *Text
- func (t *Text) ShowLineNumbers(show bool) *Text
- func (t *Text) Title(s string) *Text
- func (t *Text) TitleFunc(f func() string, bindings any) *Text
- func (t *Text) Validate(fn func(string) error) *Text
- func (t *Text) Value(v *string) *Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Confirm ¶
type Confirm struct {
// contains filtered or unexported fields
}
Confirm wraps *huh.Confirm for headless drive.
func NewConfirm ¶
func NewConfirm() *Confirm
NewConfirm returns a new Confirm wrapping huh.NewConfirm().
func (*Confirm) Affirmative ¶
Affirmative sets the affirmative label.
func (*Confirm) Description ¶
Description sets the field description.
func (*Confirm) DescriptionFunc ¶
DescriptionFunc sets a dynamic description function with bindings.
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form wraps *huh.Form and retains the huhx groups so the runner can walk them in non-interactive mode.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group wraps *huh.Group and tracks the hide predicate alongside the huhx field list so the non-interactive runner can walk groups in order, skip hidden ones, and dispatch answers to the correct field.
func NewGroup ¶
func NewGroup(fields ...field) *Group
NewGroup builds a Group from huhx field wrappers.
func (*Group) Description ¶
Description sets the group description.
func (*Group) WithHeight ¶
WithHeight sets the group height.
func (*Group) WithHide ¶
WithHide marks the group as skipped (in non-interactive mode) and hidden (in interactive mode) when hide is true. The predicate stored on the wrapper is a constant returning hide.
func (*Group) WithHideFunc ¶
WithHideFunc marks the group as skipped (in non-interactive mode) and hidden (in interactive mode) when fn returns true. Mirrors huh's WithHideFunc.
func (*Group) WithKeyMap ¶
WithKeyMap applies a key map to the group.
func (*Group) WithShowErrors ¶
WithShowErrors toggles error display for the group.
func (*Group) WithShowHelp ¶
WithShowHelp toggles the help text for the group.
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input is a thin builder over *huh.Input that captures the validator and destination pointer so the non-interactive runner can drive the field without going through huh's bubble tea loop.
func (*Input) Description ¶
Description sets the field description.
func (*Input) DescriptionFunc ¶
DescriptionFunc sets a dynamic description function.
func (*Input) Placeholder ¶
Placeholder sets the field placeholder.
func (*Input) PlaceholderFunc ¶
PlaceholderFunc sets a dynamic placeholder function.
func (*Input) Suggestions ¶
Suggestions sets the autocomplete suggestions.
func (*Input) SuggestionsFunc ¶
SuggestionsFunc sets a dynamic suggestions function.
type Mode ¶
type Mode int
Mode controls how the runner chooses between interactive and non-interactive execution.
type MultiSelect ¶
type MultiSelect[T comparable] struct { // contains filtered or unexported fields }
MultiSelect wraps *huh.MultiSelect[T] for headless drive. The non-interactive answer is a comma-separated string of option keys or values. Options provided via Options(...) are captured at construction time; options provided via OptionsFunc(...) are re-evaluated lazily inside set() so closures that depend on earlier fields' values resolve correctly.
func NewMultiSelect ¶
func NewMultiSelect[T comparable]() *MultiSelect[T]
NewMultiSelect returns a new MultiSelect wrapping huh.NewMultiSelect[T]().
func (*MultiSelect[T]) Accessor ¶
func (m *MultiSelect[T]) Accessor(a huh.Accessor[[]T]) *MultiSelect[T]
Accessor binds a custom accessor for reading and writing the value.
func (*MultiSelect[T]) Description ¶
func (m *MultiSelect[T]) Description(d string) *MultiSelect[T]
Description sets the field description.
func (*MultiSelect[T]) DescriptionFunc ¶
func (m *MultiSelect[T]) DescriptionFunc(f func() string, bindings any) *MultiSelect[T]
DescriptionFunc sets a dynamic description provider re-evaluated on bindings change.
func (*MultiSelect[T]) Filterable ¶
func (m *MultiSelect[T]) Filterable(filterable bool) *MultiSelect[T]
Filterable toggles filtering UI.
func (*MultiSelect[T]) Filtering ¶
func (m *MultiSelect[T]) Filtering(filtering bool) *MultiSelect[T]
Filtering sets the current filtering state.
func (*MultiSelect[T]) Height ¶
func (m *MultiSelect[T]) Height(h int) *MultiSelect[T]
Height sets the field height.
func (*MultiSelect[T]) Key ¶
func (m *MultiSelect[T]) Key(k string) *MultiSelect[T]
Key sets the field key used for answer lookup.
func (*MultiSelect[T]) Limit ¶
func (m *MultiSelect[T]) Limit(n int) *MultiSelect[T]
Limit sets the maximum number of selections.
func (*MultiSelect[T]) Optional ¶
func (m *MultiSelect[T]) Optional() *MultiSelect[T]
Optional marks the field as not required in non-interactive mode.
func (*MultiSelect[T]) Options ¶
func (m *MultiSelect[T]) Options(opts ...huh.Option[T]) *MultiSelect[T]
Options sets the available options statically. The wrapper retains a copy so the non-interactive runner can match answers without going through huh internals. Calling Options clears any previously set OptionsFunc.
func (*MultiSelect[T]) OptionsFunc ¶
func (m *MultiSelect[T]) OptionsFunc(f func() []huh.Option[T], bindings any) *MultiSelect[T]
OptionsFunc sets a dynamic options provider. The provider is forwarded to huh for interactive mode and is re-evaluated by the non-interactive runner at injection time so closures that depend on earlier fields' values resolve correctly. The dependent field must live in a later group than its source field (same rule as huh's interactive bindings). Calling OptionsFunc clears any previously set static Options.
func (*MultiSelect[T]) Title ¶
func (m *MultiSelect[T]) Title(t string) *MultiSelect[T]
Title sets the field title.
func (*MultiSelect[T]) TitleFunc ¶
func (m *MultiSelect[T]) TitleFunc(f func() string, bindings any) *MultiSelect[T]
TitleFunc sets a dynamic title provider re-evaluated on bindings change.
func (*MultiSelect[T]) Validate ¶
func (m *MultiSelect[T]) Validate(fn func([]T) error) *MultiSelect[T]
Validate sets the validator on both the wrapper and the inner huh field.
func (*MultiSelect[T]) Value ¶
func (m *MultiSelect[T]) Value(v *[]T) *MultiSelect[T]
Value binds a destination slice pointer.
func (*MultiSelect[T]) Width ¶
func (m *MultiSelect[T]) Width(w int) *MultiSelect[T]
Width sets the field width.
type Option ¶
type Option func(*Runner)
Option configures a Runner.
func WithAnswerFile ¶
WithAnswerFile loads answers from a YAML or JSON file. YAML is a superset of JSON so a single decoder handles both.
func WithAnswers ¶
WithAnswers supplies answers programmatically. Values are stringified via fmt.Sprintf("%v", v) before being handed to the field's setter. This has the highest precedence among answer sources.
func WithCobraFlags ¶
WithCobraFlags wires the runner to a cobra command. The runner uses the command for three things:
- Looking up each field's key as a named flag (e.g. --name) and using its value when the flag has been explicitly set.
- Reading --answer key=val pairs from a StringSlice flag named "answer" if present.
- Honouring a --non-interactive bool flag if present and set, as one of the AutoDetect inputs.
func WithEnvPrefix ¶
WithEnvPrefix sets the prefix used when looking up answers in environment variables. A field with key "name" and prefix "MYCLI" is looked up as MYCLI_NAME.
func WithNonInteractive ¶
WithNonInteractive overrides the mode selection. Default is AutoDetect.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner drives a Form either interactively (delegating to huh) or non-interactively (walking groups and injecting answers from configured sources).
type Select ¶
type Select[T comparable] struct { // contains filtered or unexported fields }
Select wraps *huh.Select[T] for headless drive. Options provided via Options(...) are captured at construction time; options provided via OptionsFunc(...) are re-evaluated lazily inside set() so closures that depend on earlier fields' values resolve correctly.
func NewSelect ¶
func NewSelect[T comparable]() *Select[T]
NewSelect returns a new Select wrapping huh.NewSelect[T]().
func (*Select[T]) Description ¶
Description sets the field description.
func (*Select[T]) DescriptionFunc ¶
DescriptionFunc sets a dynamic description with bindings.
func (*Select[T]) Options ¶
Options sets the available options statically. The wrapper retains a copy so the non-interactive runner can match answers without going through huh internals. Calling Options clears any previously set OptionsFunc.
func (*Select[T]) OptionsFunc ¶
OptionsFunc sets a dynamic options provider. The provider is forwarded to huh for interactive mode and is re-evaluated by the non-interactive runner at injection time so closures that depend on earlier fields' values resolve correctly. The dependent field must live in a later group than its source field (same rule as huh's interactive bindings). Calling OptionsFunc clears any previously set static Options.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text wraps *huh.Text for headless drive.
func (*Text) Description ¶
Description sets the field description.
func (*Text) DescriptionFunc ¶
DescriptionFunc sets the description via a dynamic function with bindings.
func (*Text) EditorExtension ¶
EditorExtension sets the file extension used by the external editor.
func (*Text) ExternalEditor ¶
ExternalEditor toggles the external editor.
func (*Text) Placeholder ¶
Placeholder sets the field placeholder.
func (*Text) PlaceholderFunc ¶
PlaceholderFunc sets the placeholder via a dynamic function with bindings.
func (*Text) ShowLineNumbers ¶
ShowLineNumbers toggles display of line numbers.