cli supports clue
parent
26f6567fb0
commit
990733200f
26
main.go
26
main.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
|
@ -21,6 +22,7 @@ type (
|
|||
}
|
||||
Question struct {
|
||||
Q string
|
||||
Clues []string
|
||||
Tags []string
|
||||
}
|
||||
Answer struct {
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ knowledge:
|
|||
questions:
|
||||
uuid1:
|
||||
q: whats a fieldset
|
||||
clues:
|
||||
- clue1 of 2
|
||||
- clue2 of 2
|
||||
tags:
|
||||
- ops
|
||||
- data-platform
|
||||
|
|
|
|||
Loading…
Reference in New Issue