Documentation ¶
Overview ¶
Package userutil provides several helpful functions for working with users.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserInput ¶
func GetUserInput(promptMessage string, options PromptOptions) (string, error)
GetUserInput issues a prompt to the user and records the user's response.
func GetYesOrNoUserInput ¶
func GetYesOrNoUserInput(promptMessage string, options PromptOptions) (bool, error)
GetYesOrNoUserInput issues a prompt and then checks if the user answered 'yes', 'y', 'no', or 'n'. Any capitalization of these inputs is valid. If the user did not provide any of these inputs then an error of type InputError is returned. If the user answered in the affirmative, then true is returned.
Types ¶
type InputError ¶
type InputError struct {
// contains filtered or unexported fields
}
func (InputError) Error ¶
func (o InputError) Error() string
func (InputError) YesNoNotProvided ¶
func (o InputError) YesNoNotProvided() bool
type PromptOptions ¶
type PromptOptions struct { // Whether or not to hide the user's input. ShouldHideInput bool // The message appended to Y/N prompts. YesNoMessage string // The string to prefix to the user input message prompt. InputPrefix string // The string to append to the user input message prompt. InputSuffix string }
PromptOptions configures how the input prompt should behave.
func (PromptOptions) InputPrefixFormat ¶
func (o PromptOptions) InputPrefixFormat() string
func (PromptOptions) InputSuffixFormat ¶
func (o PromptOptions) InputSuffixFormat() string
func (PromptOptions) YesNoSuffixFormat ¶
func (o PromptOptions) YesNoSuffixFormat() string
Click to show internal directories.
Click to hide internal directories.