prompter

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const OptionsThreshold = 15

OptionsThreshold limits the number of items displayed by default on a select prompter.

View Source
const TagName = "prompter"

TagName contains the golang tag identifier

Variables

This section is empty.

Functions

func Confirm

func Confirm(q string, p *promptui.Prompt) error

Confirm will ask a confirmation prompt and return an error if it was not accepted or nil if it was.

func Int

func Int(q string) (i int, err error)

Int creates a simple prompter that returns the value as an int.

It accepts a label.

func Select added in v0.4.0

func Select(q string, opts []string) (interface{}, error)

Select prompts a select screen for the given options and using the speficied label.

It returns an interface and an error (if exists).

func SelectRemoteOptions added in v0.4.0

func SelectRemoteOptions(q string, req *http.Request) (interface{}, error)

SelectRemoteOptions will fetch the slice of strings to present as options from the given request, it will use the default http.Client, so your request must contain all the information required for it to work, like authorization headers or any other parameter that is required by the API receiving the request.

func String

func String(q string, def string) (string, error)

String creates a simple prompter that returns the value as a string.

It accepts a label and a default value.

func Struct

func Struct(s interface{}) (sc interface{}, err error)

Struct fills the provided struct using reflection. The implementation will use the field name to prompt the user for a value.

The implementation is basic and aimed for problems that require filling multiple fields on large structs where using tags will not be feasible nor user friendly.

If you need to skip a piece of the struct, you can use the prompter tag with '-' as a value, similar to what happens with the encoding/json tag.

Types

This section is empty.

Jump to

Keyboard shortcuts

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