util

package
v0.0.0-...-0f323ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL