Documentation ¶
Index ¶
- type Optionality
- type Prompt
- func SimplePrompt(message string, required Optionality, defaultValue string) Prompt
- func SimpleSecurePrompt(message string, required Optionality, defaultValue string) Prompt
- func SingleValuePrompt(message string, hint string, values []string, required Optionality, ...) Prompt
- func YesNoPrompt(message string, hint string, required Optionality, defaultValue bool) Prompt
- type PromptValueConverter
- type PromptValueValidator
- type Prompter
- type Validity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Optionality ¶
type Optionality int
Optionality - whether thing is optional or not optional (for better visibility)
const ( // Required - is not optional Required Optionality = 1 << iota // NotRequired - is optional NotRequired )
type Prompt ¶
type Prompt struct { // Message - the prompt message Message string // ValueHint - textual hint to the user describing what they should enter ValueHint string // SecureEntry - whether or not what the user is typing should be visible SecureEntry bool // DefaultValue - the value that will be returned if no value is entered and the // entry is not required DefaultValue interface{} // Required - whether or not the entry is required Required Optionality // RetryIfNoMatch - should we re-ask for a value if no match / value was entered RetryIfNoMatch bool // FailIfNoMatch - should the entry fail if it doesn't pass validation? FailIfNoMatch bool // CaseSensitiveMatch - should we do a case sensitive check of acceptable values CaseSensitiveMatch bool // ValueConverter - logic to do conversion of the string entry to your preferred // output type ValueConverter PromptValueConverter // ValidationFunc - logic to validate the entry ValidationFunc PromptValueValidator }
Prompt - an individual request to get back information via a prompt
func SimplePrompt ¶
func SimplePrompt(message string, required Optionality, defaultValue string) Prompt
SimplePrompt - a simple prompt to get a value with no restrictions. allows for a default.
func SimpleSecurePrompt ¶
func SimpleSecurePrompt(message string, required Optionality, defaultValue string) Prompt
SimpleSecurePrompt - a simple prompt to get a value with no restrictions. entry is capture without local echo (typing not visible). allows for a default.
func SingleValuePrompt ¶
func SingleValuePrompt(message string, hint string, values []string, required Optionality, defaultValue string) Prompt
SingleValuePrompt - prompts for an answer from within a subset of valid answers. allows for a default.
func YesNoPrompt ¶
func YesNoPrompt(message string, hint string, required Optionality, defaultValue bool) Prompt
YesNoPrompt - prompts for a yes or no answer. the final value will be a boolean. allows for a default.
type PromptValueConverter ¶
PromptValueConverter - converts a provided value to a final value type
type PromptValueValidator ¶
PromptValueValidator - checks to see if the value provided matches the criteria
type Prompter ¶
type Prompter struct { Reader *bufio.Reader // Values - map of all completed values keyed on the Prompt's Message value Values map[string]interface{} // IndexedValues - all completed values based on the order they were entered IndexedValues []interface{} // TrimSpace - should we trim leading and trailing spaces? TrimSpace bool // PromptSuffix - should we add a suffix to the end of the prompt message for // all messages PromptSuffix string }
Prompter - the primary prompt controller
func (*Prompter) ClearValues ¶
func (pmt *Prompter) ClearValues()
ClearValues - clear any currently tracked values