Documentation ¶
Index ¶
- Variables
- func TransformOnlyId(answer interface{}) interface{}
- func ValidateInt64(answer interface{}) error
- type Input
- type Interface
- type Select
- type Survey
- func (x *Survey) Confirm(input *Input) (bool, error)
- func (x *Survey) InputFloat64(input *Input) (float64, error)
- func (x *Survey) InputInt64(input *Input) (int64, error)
- func (x *Survey) InputString(input *Input) (string, error)
- func (x *Survey) Password(input *Input) (string, error)
- func (x *Survey) Select(input *Select) (string, error)
- func (x *Survey) SelectMulti(input *Select) ([]string, error)
- type Transformer
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotImplemented = errors.New("survey: not implemented")
ErrNotImplemented is the error returned if a method is not implemented.
Functions ¶
func TransformOnlyId ¶
func TransformOnlyId(answer interface{}) interface{}
TransformOnlyId is a `Transformer`. It receives an answer value and returns a copy of the answer with only the first word, which expected to be the ID of the resource.
func ValidateInt64 ¶
func ValidateInt64(answer interface{}) error
Types ¶
type Input ¶
type Input struct { Message string Help string Default interface{} Required bool Validate Validator Transform Transformer }
Input holds the configuration for input prompt.
type Interface ¶
type Interface interface { // InputString gets an answer to a prompt from a user's free-form input. InputString(input *Input) (string, error) // InputInt gets an answer to a prompt from a user's free-form input. InputInt64(input *Input) (int64, error) // InputFloat64 gets an answer to a prompt from a user's free-form input. InputFloat64(input *Input) (float64, error) // Password gets a password (via hidden input) from a user's free-form input. Password(input *Input) (string, error) // Confirm prompts the user to confirm something. Confirm(input *Input) (bool, error) // Select gets the user to select an option from a list of options. Select(input *Select) (string, error) // SelectMulti gets the user to select multiple selections from a list of options. SelectMulti(input *Select) ([]string, error) }
Interface defines the interface of a survey prompter.
type Select ¶
type Select struct { Message string Help string Defaults []interface{} Options []interface{} Validate Validator Transform Transformer }
Select holds the configuration for both select and multi-select prompts.
type Survey ¶
type Survey struct { // In, Out, and Err represent the respective data streams that the survey // may act upon. They are attached directly to each prompt. In terminal.FileReader Out terminal.FileWriter Err io.Writer }
Survey holds the configuration for the survey.
type Transformer ¶
type Transformer func(answer interface{}) (newAnswer interface{})
Transformer is a function used to implement a custom logic that will result to return a different representation of the given answer.
Click to show internal directories.
Click to hide internal directories.