Documentation ¶
Index ¶
- Variables
- type Confirm
- type EventDispatcher
- type Input
- type Password
- type Prompt
- func (p *Prompt) Confirm(title, message string, defaultChoice *bool, forcedChoice *bool) (bool, error)
- func (p *Prompt) Input(title, message string, defaultResponse *string, forcedResponse *string, ...) (string, error)
- func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string, forcedResponse *string, ...) (string, error)
- func (p *Prompt) InputSecret(title, message string, flags ...ValidatorFlag) (string, error)
- func (p *Prompt) IsForced() bool
- func (p *Prompt) IsInteractive() bool
- func (p *Prompt) Select(title, message string, choices []string, defaultChoice *string, ...) (string, error)
- func (p *Prompt) SetForce(force bool)
- func (p *Prompt) SetInteractive(interactive bool)
- type Prompter
- type Select
- type ValidatorFlag
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
var ErrNoForceOption = errs.New("No force option given for forced prompt")
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) Confirm ¶
func (p *Prompt) Confirm(title, message string, defaultChoice *bool, forcedChoice *bool) (bool, error)
Confirm prompts user for yes or no response. If the prompt is non-interactive, it returns defaultChoice. If the prompt is forced, it returns forcedChoice if not nil, or defaultChoice.
func (*Prompt) Input ¶
func (p *Prompt) Input(title, message string, defaultResponse *string, forcedResponse *string, flags ...ValidatorFlag) (string, error)
Input prompts the user for input. The user can specify available validation flags to trigger validation of responses If the prompt is non-interactive, it returns defaultResponse. If the prompt is forced, it returns forcedResponse if not nil, or defaultResponse.
func (*Prompt) InputAndValidate ¶
func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string, forcedResponse *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 If the prompt is non-interactive, it returns defaultResponse. If the prompt is forced, it returns forcedResponse if not nil, or defaultResponse.
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
func (*Prompt) Select ¶
func (p *Prompt) Select(title, message string, choices []string, defaultChoice *string, forcedChoice *string) (string, error)
Select prompts the user to select one entry from multiple choices. If the prompt is non-interactive, it returns defaultChoice. If the prompt is forced, it returns forcedChoice if not nil, or defaultChoice.
func (*Prompt) SetForce ¶
SetForce enables prompts to return the force value (which is often different from the non-interactive value).
func (*Prompt) SetInteractive ¶
type Prompter ¶
type Prompter interface { Input(title, message string, defaultResponse *string, forcedResponse *string, flags ...ValidatorFlag) (string, error) InputAndValidate(title, message string, defaultResponse *string, forcedResponse *string, validator ValidatorFunc, flags ...ValidatorFlag) (string, error) Select(title, message string, choices []string, defaultResponse *string, forcedResponse *string) (string, error) Confirm(title, message string, defaultChoice *bool, forcedChoice *bool) (bool, error) InputSecret(title, message string, flags ...ValidatorFlag) (string, error) IsInteractive() bool SetInteractive(bool) SetForce(bool) IsForced() bool }
Prompter is the interface used to run our prompt from
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