gopass: Index | Files

package termio

import ""


Package Files

ask.go context.go promptpass_others.go reader.go


var (
    // Stdout is exported for tests
    Stdout io.Writer = os.Stdout
    // Stdin is exported for tests
    Stdin io.Reader = os.Stdin
    // ErrAborted is returned if the user aborts an action
    ErrAborted = fmt.Errorf("user aborted")

func AskForBool Uses

func AskForBool(ctx context.Context, text string, def bool) (bool, error)

AskForBool ask for a bool (yes or no) exactly once. The empty answer uses the specified default, any other answer is an error.

func AskForConfirmation Uses

func AskForConfirmation(ctx context.Context, text string) bool

AskForConfirmation asks a yes/no question until the user replies yes or no

func AskForInt Uses

func AskForInt(ctx context.Context, text string, def int) (int, error)

AskForInt asks for an valid interger once. If the input can not be converted to an int it returns an error

func AskForKeyImport Uses

func AskForKeyImport(ctx context.Context, key string, names []string) bool

AskForKeyImport asks for permissions to import the named key

func AskForPassword Uses

func AskForPassword(ctx context.Context, name string) (string, error)

AskForPassword prompts for a password twice until both match

func AskForString Uses

func AskForString(ctx context.Context, text, def string) (string, error)

AskForString asks for a string once, using the default if the anser is empty. Errors are only returned on I/O errors

func HasPassPromptFunc Uses

func HasPassPromptFunc(ctx context.Context) bool

HasPassPromptFunc returns true if a value for the pass prompt func has been set in this context

func WithPassPromptFunc Uses

func WithPassPromptFunc(ctx context.Context, ppf PassPromptFunc) context.Context

WithPassPromptFunc returns a context with the password prompt function set

type LineReader Uses

type LineReader struct {
    // contains filtered or unexported fields

LineReader is an unbuffered line reader

func NewReader Uses

func NewReader(r io.Reader) *LineReader

NewReader creates a new line reader

func (LineReader) Read Uses

func (lr LineReader) Read(p []byte) (int, error)

Read implements io.Reader

func (LineReader) ReadLine Uses

func (lr LineReader) ReadLine() (string, error)

ReadLine reads one line w/o buffering

type PassPromptFunc Uses

type PassPromptFunc func(context.Context, string) (string, error)

PassPromptFunc is a password prompt function

func GetPassPromptFunc Uses

func GetPassPromptFunc(ctx context.Context) PassPromptFunc

GetPassPromptFunc will return the password prompt func or a default one Note: will never return nil

Package termio imports 12 packages (graph). Updated 2018-08-19. Refresh now. Tools for package owners.