Documentation ¶
Overview ¶
Package prompt provides functionality to retrieve free-form text, selection, and confirmation input from the user via a terminal.
Index ¶
- Variables
- func RequireNonEmpty(v interface{}) error
- type Option
- type Prompt
- func (p Prompt) Confirm(message, help string, promptOpts ...Option) (bool, error)
- func (p Prompt) Get(message, help string, validator ValidatorFunc, promptOpts ...Option) (string, error)
- func (p Prompt) GetSecret(message, help string, promptOpts ...Option) (string, error)
- func (p Prompt) MultiSelect(message, help string, options []string, promptOpts ...Option) ([]string, error)
- func (p Prompt) SelectOne(message, help string, options []string, promptOpts ...Option) (string, error)
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyOptions = errors.New("list of provided options is empty")
ErrEmptyOptions indicates the input options list was empty.
Functions ¶
func RequireNonEmpty ¶ added in v0.3.0
func RequireNonEmpty(v interface{}) error
RequireNonEmpty returns an error if v is a zero-value.
Types ¶
type Option ¶
type Option func(*prompt)
Option is a functional option to configure the prompt.
func WithDefaultInput ¶
WithDefaultInput sets a default message for an input prompt.
func WithFinalMessage ¶
WithFinalMessage sets a final message that replaces the question prompt once the user enters an answer.
func WithTrueDefault ¶
func WithTrueDefault() Option
WithTrueDefault sets the default for a confirm prompt to true.
type Prompt ¶
type Prompt func(survey.Prompt, interface{}, ...survey.AskOpt) error
Prompt abstracts the survey.Askone function.
func (Prompt) Get ¶
func (p Prompt) Get(message, help string, validator ValidatorFunc, promptOpts ...Option) (string, error)
Get prompts the user for free-form text input.
type ValidatorFunc ¶
type ValidatorFunc func(interface{}) error
ValidatorFunc defines the function signature for validating inputs.