prompt

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToSelect

func ToSelect(options InputOptions) (int, error)

ToSelect prompts the user to select an option from the provided `options.Options` argument. On success, returns the selected index. Returns `ErrorSkipped` if the user indicated to skip, returns `ErrorInput` on input validation errors, returns `ErrorSystem` on system errors

Types

type InputError added in v0.1.18

type InputError int
const (
	ErrorSkipped InputError = -1
	ErrorInput   InputError = -2
	ErrorSystem  InputError = -3
)

type InputHelper added in v0.1.18

type InputHelper InputOptions

InputHelper implements helper functions over the InputOptions structure

func (InputHelper) GetData added in v0.1.18

func (ih InputHelper) GetData() string

GetData retrieves the read input

func (InputHelper) PrintAfterMessage added in v0.1.18

func (ih InputHelper) PrintAfterMessage()

PrintAfterMessage prints the message to be displayed after the possible options have been printed

func (InputHelper) PrintBeforeMessage added in v0.1.18

func (ih InputHelper) PrintBeforeMessage()

PrintBeforeMessage prints the message to be displayed before the possible options are printed

func (InputHelper) PrintOptions added in v0.1.18

func (ih InputHelper) PrintOptions()

PrintOptions prints the possible options for the user to select

func (*InputHelper) ReadInput added in v0.1.18

func (ih *InputHelper) ReadInput() error

ReadInput reads in a user's input

type InputOptions added in v0.1.18

type InputOptions struct {
	BeforeMessage     string
	AfterMessage      string
	SerializedOptions []string
	Type              InputType
	Reader            io.Reader
	// contains filtered or unexported fields
}

type InputType added in v0.1.18

type InputType string
const (
	TypeInt    InputType = "int"
	TypeUInt   InputType = "uint"
	TypeString InputType = "string"
	TypeBool   InputType = "bool"
)

Jump to

Keyboard shortcuts

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