config: add ReadNonEmptyLine utility function

This commit is contained in:
Nick Craig-Wood 2019-08-30 11:50:22 +01:00
parent 74f6300875
commit 262ba28dec

View File

@ -624,6 +624,16 @@ var ReadLine = func() string {
return strings.TrimSpace(line)
}
// ReadNonEmptyLine prints prompt and calls Readline until non empty
func ReadNonEmptyLine(prompt string) string {
result := ""
for result == "" {
fmt.Print(prompt)
result = strings.TrimSpace(ReadLine())
}
return result
}
// Command - choose one
func Command(commands []string) byte {
opts := []string{}