Documentation ¶
Index ¶
- Variables
- func PromptMultiLine(in *os.File, out *os.File, stderr io.Writer, ...) (string, error)
- func PromptSingleLine(in *os.File, out *os.File, stderr io.Writer, ...) (string, error)
- func Select(message string, options []string, defaultOption string) (string, error)
- type ConfirmResult
- type ErrAbortAction
- type Prompt
- func (p *Prompt) EncryptionPassphrase(encryptedData string, initPassphrase string, message string) (string, error)
- func (p *Prompt) Input(label string, defaultValue string, required bool, hideEntered bool) (string, error)
- func (p *Prompt) Password(label string, message string) (string, error)
- func (p *Prompt) PasswordWithConfirm(label string, message string) (string, error)
- func (p *Prompt) ShowMessage(m string)
- func (p *Prompt) TOTPCode(host, username string, code string, client *c8y.Client, initRequest string) (string, error)
- func (p *Prompt) Username(label string, defaultValue string) (string, error)
- type PromptWithPostValidate
- type Validate
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorPasswordMismatch error when the passwords entered by a user do not match ErrorPasswordMismatch = fmt.Errorf("passwords do not match") ErrorUserCancelled = fmt.Errorf("user cancelled input") )
var ErrCancelAll = errors.New("cancel all")
ErrCancelAll cancel all operations
Functions ¶
func PromptMultiLine ¶
Types ¶
type ConfirmResult ¶
type ConfirmResult int
ConfirmResult confirm result
const ( // ConfirmYesToAll user has selected yes to current and all future operations ConfirmYesToAll ConfirmResult = iota + 1 // ConfirmYes user has selected yes to current operation ConfirmYes // ConfirmNo user has selected no to current operation ConfirmNo // ConfirmNoToAll user has selected no to current and all future operations ConfirmNoToAll )
func Confirm ¶
func Confirm(prefix, label string, target, defaultValue string, force bool) (ConfirmResult, error)
Confirm prompts for a confirmation from the user
func (ConfirmResult) FromString ¶
func (c ConfirmResult) FromString(name string) ConfirmResult
func (ConfirmResult) String ¶
func (c ConfirmResult) String() string
type ErrAbortAction ¶
ErrAbortAction indicates that the user did not confirm an action
func (ErrAbortAction) Error ¶
func (e ErrAbortAction) Error() string
type Prompt ¶
Prompt used to provide various interactive prompts which can be used within the cli
func NewPrompt ¶
NewPrompt returns a new Prompt which can be used to prompt the user for different information
func (*Prompt) EncryptionPassphrase ¶
func (p *Prompt) EncryptionPassphrase(encryptedData string, initPassphrase string, message string) (string, error)
EncryptionPassphrase prompt for the encryption passphrase, and test the passphrase against the encrypted content to see if it is valid
func (*Prompt) PasswordWithConfirm ¶
PasswordWithConfirm prompts the user for a password and confirms it by getting the user to type it in again
func (*Prompt) ShowMessage ¶
type PromptWithPostValidate ¶
type PromptWithPostValidate struct { Attempts int MaxAttempts int PostValidate func(string) error // contains filtered or unexported fields }
func NewPromptWithPostValidate ¶
func NewPromptWithPostValidate(p *promptui.Prompt, validate func(string) error) *PromptWithPostValidate
NewPromptWithPostValidate create a new prompt with a lazy validation function which is only run when the user hits enter.
func (*PromptWithPostValidate) IsUserCancelled ¶
func (p *PromptWithPostValidate) IsUserCancelled(err error) bool
func (*PromptWithPostValidate) Run ¶
func (p *PromptWithPostValidate) Run() (string, error)
Run prompts the user for input