Documentation ¶
Index ¶
- Constants
- func Confirm(q string, p *promptui.Prompt) error
- func Int(q string) (i int, err error)
- func Select(q string, opts []string) (interface{}, error)
- func SelectRemoteOptions(q string, req *http.Request) (interface{}, error)
- func String(q string, def string) (string, error)
- func Struct(s interface{}) (sc interface{}, err error)
Constants ¶
const OptionsThreshold = 15
OptionsThreshold limits the number of items displayed by default on a select prompter.
const TagName = "prompter"
TagName contains the golang tag identifier
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm will ask a confirmation prompt and return an error if it was not accepted or nil if it was.
func Select ¶ added in v0.4.0
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
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 ¶
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.