prompt

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

Types

type Prompt

type Prompt struct {
	Logger *logger.Logger
}

Prompt used to provide various interactive prompts which can be used within the cli

func NewPrompt

func NewPrompt(l *logger.Logger) *Prompt

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) Password

func (p *Prompt) Password(label string, message string) (string, error)

Password prompts the user for a password without confirmation

func (*Prompt) PasswordWithConfirm

func (p *Prompt) PasswordWithConfirm(label string, message string) (string, error)

PasswordWithConfirm prompts the user for a password and confirms it by getting the user to type it in again

func (*Prompt) ShowMessage

func (p *Prompt) ShowMessage(m string)

func (*Prompt) TOTPCode

func (p *Prompt) TOTPCode(host, username string, code string, client *c8y.Client, initRequest string) (string, error)

TOTPCode prompts for a TOTP code and validates using the given Cumulocity client

func (*Prompt) Username

func (p *Prompt) Username(label string, defaultValue string) (string, error)

Username prompts for a username on the console

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

type Validate

type Validate func(string) error

Validate function used to validate the user's input in a prompt ui

type Validator

type Validator interface {
	Validate(string) error
}

Jump to

Keyboard shortcuts

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