prompt

package
v0.0.0-...-d29143a Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPrompt = errors.New("No prompt stub")
View Source
var SurveyAskOne = func(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error {
	err := survey.AskOne(p, response, opts...)
	if err != nil {
		if errors.Is(err, terminal.InterruptErr) {
			return cmdutil.ErrExecutionCanceledByUser
		}
		return err
	}
	return nil
}

SurveyAskOne helper method with user interrupt check

Functions

func AskConfirmation

func AskConfirmation(m ...string) error

AskConfirmation make sure user confirm action, otherwise abort.

func GetPassphrase

func GetPassphrase(stdIn io.Reader, canPrompt, hasStdin bool, message string) (string, error)

GetPassphrase check stdin if we have anything, and use that as passphrase otherwise, if we can prompt, Prompt user input

func PasswordConfirmation

func PasswordConfirmation(message string) (string, error)

Types

type AskStubber

type AskStubber struct {
	// contains filtered or unexported fields
}

func InitAskStubber

func InitAskStubber(t *testing.T) (*AskStubber, func())

func (*AskStubber) Stub

func (as *AskStubber) Stub(stubbedQuestions []*QuestionStub)

func (*AskStubber) StubOne

func (as *AskStubber) StubOne(value interface{})

func (*AskStubber) StubPrompt

func (as *AskStubber) StubPrompt(msg string) *QuestionStub

type PromptStub

type PromptStub struct {
	Value   interface{}
	Default bool
}

type QuestionStub

type QuestionStub struct {
	Name    string
	Value   interface{}
	Default bool
	// contains filtered or unexported fields
}

func (*QuestionStub) AnswerDefault

func (s *QuestionStub) AnswerDefault() *QuestionStub

func (*QuestionStub) AnswerWith

func (s *QuestionStub) AnswerWith(v interface{}) *QuestionStub

Jump to

Keyboard shortcuts

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