Documentation
¶
Index ¶
- Variables
- type ConsolePrompter
- func (c ConsolePrompter) Choose(message string, choices []string, opts ...Option) (string, error)
- func (c ConsolePrompter) Password(message string, opts ...Option) (string, error)
- func (c ConsolePrompter) Prompt(message string, opts ...Option) (string, error)
- func (c ConsolePrompter) YesNo(message string, opts ...Option) (bool, error)
- type Option
- type Prompter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUserCancel is returned when the user cancels the prompt instead of answering it. ErrUserCancel = errors.New("operation canceled by the user") // ErrNotSupported is returned by the prompter when it doesn't support some feature. ErrNotSupported = errors.New("prompt not supported") )
Functions ¶
This section is empty.
Types ¶
type ConsolePrompter ¶
type ConsolePrompter struct{}
func Console ¶
func Console() *ConsolePrompter
func (ConsolePrompter) Password ¶
func (c ConsolePrompter) Password(message string, opts ...Option) (string, error)
type Prompter ¶
type Prompter interface {
// Prompt prompts the user for input.
Prompt(message string, opts ...Option) (answer string, err error)
// Password prompts the user for password input.
Password(message string, opts ...Option) (answer string, err error)
// YesNo asks the user a yes/no question.
YesNo(message string, opts ...Option) (answer bool, err error)
// Choose asks the user to choose from a set of options.
Choose(message string, options []string, opts ...Option) (choice int, err error)
}
Prompter is the interface satisfied by prompt agents.
Click to show internal directories.
Click to hide internal directories.