diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2017-05-04 23:06:21 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2017-05-04 23:06:21 +0200 |
| commit | 7e6b0b46c5adb4ed6ccb0cd890ccc2367ec620a4 (patch) | |
| tree | 65099c707d22f247c9e2546884851f0072664d58 /pkg/util | |
| parent | ec4270c43f1ddd37d1eb19da5db78129b93f72b7 (diff) | |
| download | gofu-7e6b0b46c5adb4ed6ccb0cd890ccc2367ec620a4.tar.gz | |
move rtree from util.Prompt to cli.Query
Diffstat (limited to 'pkg/util')
| -rw-r--r-- | pkg/util/util.go | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/pkg/util/util.go b/pkg/util/util.go index 8d2b0bf..8cdf147 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -21,7 +21,6 @@ package util import ( "bufio" "fmt" - "io" "os" "sort" "strings" @@ -52,44 +51,6 @@ func FatalIfError(err error) { var stdin = bufio.NewReader(os.Stdin) -//Prompt prints the question, then waits for the user to press one of the -//possible answer keys. Answer keys will automatically be converted to lower -//case and returned as such. -// -// choice := Prompt("(y)es or (n)o", []string{"y","n"}) -// //choice is either "y" or "n" -func Prompt(out io.Writer, question string, answers []string) string { - for idx, answer := range answers { - answers[idx] = strings.ToLower(answer) - } - - out.Write([]byte(">> " + strings.TrimSpace(question) + " ")) - for { - input, err := stdin.ReadString('\n') - FatalIfError(err) - input = strings.TrimSpace(input) - for _, answer := range answers { - if strings.ToLower(input) == answer { - return answer - } - } - - //user typed gibberish - ask again - out.Write([]byte("Please type ")) - for idx, answer := range answers { - if idx > 0 { - if idx == len(answers)-1 { - out.Write([]byte(" or ")) - } else { - out.Write([]byte(", ")) - } - } - out.Write([]byte("'" + answer + "'")) - } - out.Write([]byte(": ")) - } -} - //ReadLine reads a line from stdin, with whitespace already trimmed. func ReadLine() string { input, err := stdin.ReadString('\n') |
