prompts

package
v2.24.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForChoice added in v2.22.0

func AskForChoice(ctx context.Context, prompt string, choices *utils.OrderedMap[string, string]) (string, error)

func AskForConfirmation

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

AskForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Typically, you should use fmt to print out a question before calling askForConfirmation. E.g. fmt.Println("WARNING: Are you sure? (yes/no)")

func AskForCredentials

func AskForCredentials(ctx context.Context, prompt string) (string, string, error)

func AskForPassword

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

func NewContext

func NewContext(ctx context.Context, provider PromptProvider) context.Context

func Prompt

func Prompt(ctx context.Context, password bool, message string) (string, error)

Types

type PromptProvider

type PromptProvider interface {
	Prompt(ctx context.Context, password bool, message string) (string, error)
}

func FromContext

func FromContext(ctx context.Context) PromptProvider

type SimplePromptProvider

type SimplePromptProvider struct {
	Out *os.File
}

func (*SimplePromptProvider) Prompt

func (pp *SimplePromptProvider) Prompt(ctx context.Context, password bool, message string) (string, error)

type StatusAndStdinPromptProvider

type StatusAndStdinPromptProvider struct {
}

func (*StatusAndStdinPromptProvider) Prompt

func (pp *StatusAndStdinPromptProvider) Prompt(ctx context.Context, password bool, message string) (string, error)

Jump to

Keyboard shortcuts

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