Documentation ¶
Index ¶
- type Confirm
- type EventDispatcher
- type Input
- type Password
- type Prompt
- func (p *Prompt) Confirm(title, message string, defaultChoice *bool) (bool, error)
- func (p *Prompt) Input(title, message string, defaultResponse *string, flags ...ValidatorFlag) (string, error)
- func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string, validator ValidatorFunc, ...) (string, error)
- func (p *Prompt) InputSecret(title, message string, flags ...ValidatorFlag) (string, error)
- func (p *Prompt) IsInteractive() bool
- func (p *Prompt) Select(title, message string, choices []string, defaultChoice *string) (string, error)
- type Prompter
- type Select
- type ValidatorFlag
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventDispatcher ¶
type EventDispatcher interface {
EventWithLabel(category, action string, label string, dim ...*dimensions.Values)
}
type Prompt ¶
type Prompt struct {
// contains filtered or unexported fields
}
Prompt is our main prompting struct
func (*Prompt) Input ¶
func (p *Prompt) Input(title, message string, defaultResponse *string, flags ...ValidatorFlag) (string, error)
Input prompts the user for input. The user can specify available validation flags to trigger validation of responses
func (*Prompt) InputAndValidate ¶
func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string, validator ValidatorFunc, flags ...ValidatorFlag) (string, error)
InputAndValidate prompts an input field and allows you to specfiy a custom validation function as well as the built in flags
func (*Prompt) InputSecret ¶
func (p *Prompt) InputSecret(title, message string, flags ...ValidatorFlag) (string, error)
InputSecret prompts the user for input and obfuscates the text in stdout. Will fail if empty.
func (*Prompt) IsInteractive ¶
IsInteractive checks if the prompts can be interactive or should just return default values
type Prompter ¶
type Prompter interface { Input(title, message string, defaultResponse *string, flags ...ValidatorFlag) (string, error) InputAndValidate(title, message string, defaultResponse *string, validator ValidatorFunc, flags ...ValidatorFlag) (string, error) Select(title, message string, choices []string, defaultResponse *string) (string, error) Confirm(title, message string, defaultChoice *bool) (bool, error) InputSecret(title, message string, flags ...ValidatorFlag) (string, error) IsInteractive() bool }
Prompter is the interface used to run our prompt from, useful for mocking in tests
type ValidatorFlag ¶
type ValidatorFlag int
ValidatorFlag represents flags for prompt functions to change their behavior on.
const ( // InputRequired requires that the user provide input InputRequired ValidatorFlag = iota )
type ValidatorFunc ¶
type ValidatorFunc = survey.Validator
ValidatorFunc is a function pass to the Prompter to perform validation on the users input