This repository has been archived on 2021-03-25. You can view files and clone it, but cannot push or open issues/pull-requests.
2021-03-24 11:21:06 +00:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
// String prompts a user for a string and returns the result.
|
|
|
|
func GetString(prompt string) string {
|
|
|
|
t.SetPrompt(prompt)
|
|
|
|
s, err := t.ReadLine()
|
|
|
|
must(err)
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2021-03-24 11:24:17 +00:00
|
|
|
func GetPassword(prompt string) string {
|
|
|
|
s, err := t.ReadPassword(prompt)
|
|
|
|
must(err)
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2021-03-24 11:21:06 +00:00
|
|
|
func GetInt(prompt string) int {
|
|
|
|
for {
|
|
|
|
s := GetString(prompt)
|
|
|
|
|
|
|
|
value := int(0)
|
|
|
|
|
|
|
|
n, err := fmt.Sscanf(s, "%d", &value)
|
|
|
|
if n != 1 || err != nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
}
|