prompts

package
v0.0.0-...-493bf59 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPrompts

type IPrompts interface {
	EmailPassword(existingEmail, existingPassword string) (string, string, error)
	KeyPassphrase(string) string
	Password(msg string) string
	PHI() error
	YesNo(msg, prompt string) error
	OTP(string) string
	GenericPrompt(msg, prompt string, validOptions []string) string
	CaptureInput(msg string) string
}

IPrompts is the interface in which to interact with the user and accept input.

func New

func New() IPrompts

New returns a new instance of IPrompts

type SPrompts

type SPrompts struct{}

SPrompts is a concrete implementation of IPrompts

func (*SPrompts) CaptureInput

func (p *SPrompts) CaptureInput(msg string) string

CaptureInput prompts the user with the given msg and reads input until a newline is encountered. The input is returned with newlines stripped. The prompt and the input will be on the same line when shown to the user.

func (*SPrompts) EmailPassword

func (p *SPrompts) EmailPassword(existingEmail, existingPassword string) (string, string, error)

EmailPassword prompts a user to enter their email and password.

func (*SPrompts) GenericPrompt

func (p *SPrompts) GenericPrompt(msg, prompt string, validOptions []string) string

GenericPrompt prompts the user and validates the input against the list of given case-insensitive valid options. The user's choice is returned.

func (*SPrompts) KeyPassphrase

func (p *SPrompts) KeyPassphrase(filepath string) string

KeyPassphrase prompts a user to enter a passphrase for a named key.

func (*SPrompts) OTP

func (p *SPrompts) OTP(preferredMode string) string

OTP prompts for a one-time password and returns the value.

func (*SPrompts) PHI

func (p *SPrompts) PHI() error

PHI prompts a user to accept liability for downloading PHI to their local machine.

func (*SPrompts) Password

func (p *SPrompts) Password(msg string) string

Password prompts the user for a password displaying the given message. The password will be hidden while typed. A newline is not added to the given message. If a newline is required, it should be part of the passed in string.

func (*SPrompts) YesNo

func (p *SPrompts) YesNo(msg, prompt string) error

YesNo outputs a given message and waits for a user to answer `y/n`. If yes, flow continues as normal. If no, an error is returned. The given message SHOULD contain the string "(y/n)" or some other form of y/n indicating that the user needs to type in y or n. This method does not do that for you. The message will not have a new line appended to it. If you require a newline, add this to the given message.

Jump to

Keyboard shortcuts

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