Documentation ¶
Index ¶
- type QuestionPrompt
- func (qp QuestionPrompt) ApplyDefault(question string, predef string) string
- func (qp QuestionPrompt) RepeatIfEmpty(question string) string
- func (qp QuestionPrompt) RepeatPasswordIfEmpty(question string) string
- func (qp QuestionPrompt) RepeatPasswordUntilValid(question string, isValid func(string) (bool, error)) string
- func (qp QuestionPrompt) RepeatUntilValid(question string, isValid func(string) (bool, error)) string
- type QuestionPrompter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QuestionPrompt ¶
type QuestionPrompt struct{}
QuestionPrompt implements QuestionPrompter and allows us to request the user a question and handles the answer in different ways
func NewQuestionPrompt ¶
func NewQuestionPrompt() *QuestionPrompt
NewQuestionPrompt constructor for QuestionPrompt
func (QuestionPrompt) ApplyDefault ¶
func (qp QuestionPrompt) ApplyDefault(question string, predef string) string
ApplyDefault if the answer is empty it returns a default value
func (QuestionPrompt) RepeatIfEmpty ¶
func (qp QuestionPrompt) RepeatIfEmpty(question string) string
RepeatIfEmpty requires the user to answer the question. It repeats the question until he answers.
func (QuestionPrompt) RepeatPasswordIfEmpty ¶
func (qp QuestionPrompt) RepeatPasswordIfEmpty(question string) string
RepeatPasswordIfEmpty requires the user to answer the question by inserting an answer that wont be shown when is typed. It repeats the question until he answers.
func (QuestionPrompt) RepeatPasswordUntilValid ¶
func (qp QuestionPrompt) RepeatPasswordUntilValid(question string, isValid func(string) (bool, error)) string
RepeatPasswordUntilValid ask the same question to the user until the isValid() callback returns true
func (QuestionPrompt) RepeatUntilValid ¶
func (qp QuestionPrompt) RepeatUntilValid(question string, isValid func(string) (bool, error)) string
RepeatUntilValid ask the same question to the user until the isValid() callback returns true
type QuestionPrompter ¶
type QuestionPrompter interface { ApplyDefault(string, string) string RepeatIfEmpty(string) string RepeatUntilValid(string, func(string) (bool, error)) string RepeatPasswordIfEmpty(string) string RepeatPasswordUntilValid(string, func(string) (bool, error)) string }
QuestionPrompter prints a question in the stdout and handle the response by applying a default value or repeating the question until a specific condition is validated