prompt

package
v0.0.0-...-3746c95 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPasswordPrompt is used if no prompt is specified on the command
	// line and one is required any of the options
	DefaultPasswordPrompt PasswordPrompt = PromptFromTerminal()

	ErrTwoDifferentPasswords = errors.New("entries do not match")
	ErrPromptDisabled        = errors.New("prompt disabled")

	// PromptDisabled prevents prompting for a password. May be useful
	// where there must be no user interaction.
	PromptDisabled PasswordPrompt = new(noPrompt)
)

Functions

This section is empty.

Types

type BufferPrompt

type BufferPrompt []byte

func (*BufferPrompt) Prompt

func (b *BufferPrompt) Prompt(_ string, _ bool) ([]byte, error)

type PasswordPrompt

type PasswordPrompt interface {
	Prompt(userPrompt string, twice bool) ([]byte, error)
}

PasswordPrompt can retrieve a password from somewhere. userPrompt is some text that should be meaningful to the use i.e. a request for a password and path to a file being decrypted. if twice is true then the user will be prompted twice for the input and both values must batch or an error is returned. For prompt methods that do not involve a human the twice argument is ignored.

func PromptFromBuffer

func PromptFromBuffer(b []byte) PasswordPrompt

func PromptFromFile

func PromptFromFile(path string, options ...util.DelayOpenReadOption) PasswordPrompt

func PromptFromStream

func PromptFromStream(r io.Reader) PasswordPrompt

func PromptFromString

func PromptFromString(s string) PasswordPrompt

func PromptFromTerminal

func PromptFromTerminal() PasswordPrompt

Jump to

Keyboard shortcuts

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