inputs

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package inputs handles the user interactions

Index

Constants

View Source
const (
	// FlagUsername is the flag name for username.
	FlagUsername = "username"
	// FlagPassword is the flag name for password.
	FlagPassword = "password"
	// FlagLabels is the flag name for labels.
	FlagLabels = "labels"
	// FlagMasterPassword is the flag name for masterPassword.
	FlagMasterPassword = "masterPassword"
	// FlagDescription is the flag name for description.
	FlagDescription = "description"
	// FlagNewMasterPassword is the flag name for new masterPassword.
	FlagNewMasterPassword = "newMasterPassword"
	// FlagShowPassword flag
	FlagShowPassword = "show-pass"
)
View Source
const (
	// PromptUsername is the prompt name for username
	PromptUsername = "Username"
	// PromptPassword is the prompt name for password
	PromptPassword = "Password"
	// PromptLabels is the flag name for labels.
	PromptLabels = "Labels"
	// PromptMasterPassword is the prompt name for masterPassword.
	PromptMasterPassword = "Master password"
	// PromptDescription is the prompt name for description.
	PromptDescription = "Description"
	// ErrMSGCannotPrompt is an error message
	ErrMSGCannotPrompt = "cannot prompt for %s"
	// ErrMsgCannotGetInput is an error message
	ErrMsgCannotGetInput = "cannot get input"
	// ErrMsgCannotGetFlag is an error message
	ErrMsgCannotGetFlag = "cannot get value of %s flag"
	// ErrMsgMasterPasswordMissMatch is an error message
	ErrMsgMasterPasswordMissMatch = "master password doesn't match"
	// ErrMsgPasswordMissMatch is an error message
	ErrMsgPasswordMissMatch = "password doesn't match"
	// MinPasswordCharacters is the allowed minimum number of characters for a password.
	MinPasswordCharacters = 6
	// MinUsernameCharacters is the allowed minimum number of characters for a username.
	MinUsernameCharacters = 6
)

Variables

This section is empty.

Functions

func FromFlagsForPasswordEntry added in v0.7.0

func FromFlagsForPasswordEntry(cmd *cobra.Command, uN, password, mPassword, desc *string, labels *[]string) error

FromFlagsForPasswordEntry functions gets the input values required for Password entry from flags.

func FromPromptForPasswordEntry added in v0.7.0

func FromPromptForPasswordEntry(uN, password, mPassword, desc *string, labels *[]string) error

FromPromptForPasswordEntry functions gets the input values required for Password entry by prompting.

func GetFlagBoolVal

func GetFlagBoolVal(cmd *cobra.Command, flag string) (bool, error)

GetFlagBoolVal method returns the Boolean flag value.

func GetFlagIntVal added in v0.5.0

func GetFlagIntVal(cmd *cobra.Command, flag string) (int, error)

GetFlagIntVal method returns the int flag value.

func GetFlagStringArrayVal

func GetFlagStringArrayVal(cmd *cobra.Command, flag string) ([]string, error)

GetFlagStringArrayVal method returns the String array flag value.

func GetFlagStringVal

func GetFlagStringVal(cmd *cobra.Command, flag string) (string, error)

GetFlagStringVal method returns the String flag value.

func HasProvidedValidID

func HasProvidedValidID() func(cmd *cobra.Command, args []string) error

HasProvidedValidID returns a function which validates the ID input.

func HasProvidedValidIDLabel added in v0.7.0

func HasProvidedValidIDLabel() func(cmd *cobra.Command, args []string) error

HasProvidedValidIDLabel returns a function which validates the Label input.

func IsArgValid

func IsArgValid(arg string) bool

IsArgValid method check whether the CMD arg are valid or not.

func IsPasswordValid

func IsPasswordValid(passphrase string) bool

IsPasswordValid method check whether the FlagPassword is valid or not.

func IsValidSingleArg

func IsValidSingleArg(args []string) bool

IsValidSingleArg method check whether the CMD args are valid or not.

func PromptForDescWithDefault added in v0.9.1

func PromptForDescWithDefault(defaultVal string) (string, error)

PromptForDescWithDefault prompt for description with a default value and returns the chosen value.

func PromptForDescription added in v0.9.1

func PromptForDescription() (string, error)

PromptForDescription function prompts for description and returns the input.

func PromptForLabels added in v0.5.0

func PromptForLabels() ([]string, error)

PromptForLabels prompts for labels and returns the given labels.

func PromptForMPassword added in v0.5.0

func PromptForMPassword() (string, error)

PromptForMPassword prompts for the master password and returns master password.

func PromptForMPasswordSecondTime added in v0.6.0

func PromptForMPasswordSecondTime(currentPassword string) (string, error)

PromptForMPasswordSecondTime function prompts for master password for second time to validate and returns the input.

func PromptForNewMPassword added in v0.5.0

func PromptForNewMPassword() (string, error)

PromptForNewMPassword prompts for a new master password and returns master password.

func PromptForPassword

func PromptForPassword() (string, error)

PromptForPassword function prompts for password and returns the input.

func PromptForPasswordSecondTime added in v0.6.0

func PromptForPasswordSecondTime(currentPassword string) (string, error)

PromptForPasswordSecondTime function prompts for password for second time to validate and returns the input.

func PromptForPasswordWithDefault added in v0.5.0

func PromptForPasswordWithDefault(label, defaultVal string, validate promptui.ValidateFunc) (string, error)

PromptForPasswordWithDefault function prompts for a password with a choice of default value and returns the chosen value.

func PromptForSelect

func PromptForSelect(l string, size int, items []PromptSelectInfo) (string, error)

PromptForSelect start selection and return the selected value.

func PromptForString

func PromptForString(label string, validate promptui.ValidateFunc) (string, error)

PromptForString function prompt for string and returns the input.

func PromptForStringWithDefault added in v0.5.0

func PromptForStringWithDefault(label, defaultVal string, validate promptui.ValidateFunc) (string, error)

PromptForStringWithDefault function prompts for a string with a choice of default value and returns the chosen value.

func PromptForUserPasswordWithDefault added in v0.5.0

func PromptForUserPasswordWithDefault(defaultVal string) (string, error)

PromptForUserPasswordWithDefault function prompts for a user password with a choice of default value and returns the chosen value.

func PromptForUsername added in v0.5.0

func PromptForUsername() (string, error)

PromptForUsername prompt for username and returns the value.

func PromptForUsernameWithDefault added in v0.5.0

func PromptForUsernameWithDefault(defaultVal string) (string, error)

PromptForUsernameWithDefault prompt for username with a default value and returns the chosen value.

Types

type PromptSelectInfo added in v0.9.1

type PromptSelectInfo struct {
	ID          string
	Description string
}

PromptSelectInfo represents the information for prompt select.

Jump to

Keyboard shortcuts

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