diff --git a/main.go b/main.go index 73a64cf..8b3ba7a 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "strings" "time" "gopkg.in/yaml.v2" @@ -20,8 +21,9 @@ type ( PushAnswer(string, string, string, bool) error } Question struct { - Q string - Tags []string + Q string + Clues []string + Tags []string } Answer struct { Q string @@ -55,8 +57,25 @@ func Main() error { } question := db.Question(q) fmt.Printf("> Q: %s\n", question.Q) - fmt.Printf("> %+v\n\t", question.Tags) - response := readline() + fmt.Printf("> %+v\n", question.Tags) + var response string + for i := range question.Clues { + if i == 0 { + fmt.Printf("> /clue for a clue\n") + } + response = readline() + if response != "/clue" { + break + } + fmt.Printf("> %s", question.Clues[i]) + if i+1 < len(question.Clues) { + fmt.Printf(" | /clue for another clue") + } + fmt.Printf("\n") + } + if len(question.Clues) == 0 || response == "/clue" { + response = readline() + } if lastAnswer := db.Answer(db.LastAnswer(user, q).A); lastAnswer.A != "" { fmt.Printf("> Last time, you responded:\n\t%s\n", lastAnswer.A) } @@ -74,9 +93,10 @@ func Main() error { } func readline() string { + fmt.Printf("\t") reader := bufio.NewReader(os.Stdin) text, _ := reader.ReadString('\n') - return text + return strings.TrimSpace(text) } func NewDB() (DB, error) { diff --git a/testdata/sample.yaml b/testdata/sample.yaml index 1a9ad67..e601778 100644 --- a/testdata/sample.yaml +++ b/testdata/sample.yaml @@ -2,6 +2,9 @@ knowledge: questions: uuid1: q: whats a fieldset + clues: + - clue1 of 2 + - clue2 of 2 tags: - ops - data-platform