prompt

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Unlicense Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SPACE  = 32
	UP     = 65
	DOWN   = 66
	ESCAPE = 27
	RETURN = 13
	A      = 97
	U      = 117

	ROW_OFFSET     = 2
	DEFAULT_COLUMN = 0
)

Variables

View Source
var ErrNoOptionsProvided = fmt.Errorf("no options were provided")
View Source
var ErrUserCancelled = fmt.Errorf("User cancelled")

ErrUserCancelled means the user cancelled the current action

View Source
var ErrUserChoiceInvalid = fmt.Errorf("User choice invalid")

ErrUserChoiceInvalid means the user chose an option which was not valid

Functions

func ChooseFromList

func ChooseFromList(message string, options []string, colourOverrides ...string) (int, string, error)

ChooseFromList prompts the user to select an item from a list. It return the chosen list index, the chosen list item value, or an error

func ChooseFromMultiList

func ChooseFromMultiList(message string, options []string, colourOverrides ...string) ([]int, []string, error)

func EnterInput

func EnterInput(msg string) string

EnterInput requests input from the user with the given message, and returns any user input that was gathered until a newline was entered

func EnterInputWithDefault

func EnterInputWithDefault(msg, defaultValue string) string

EnterInputWithDefault requests input from the user with the given message and returns a default if the input is empty

func EnterPassword

func EnterPassword(msg string) string

EnterPassword requests input from the user with the given message, hiding that input, and returns any user input that was gathered until a newline was entered

func EnterPasswordE added in v1.5.0

func EnterPasswordE(msg string) (string, error)

EnterPasswordE requests input from the user with the given message, hiding that input, and returns any user input that was gathered until a newline was entered - returning an error if one occurred

Types

This section is empty.

Jump to

Keyboard shortcuts

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