cli supports clue
parent
26f6567fb0
commit
990733200f
26
main.go
26
main.go
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
@ -21,6 +22,7 @@ type (
|
||||||
}
|
}
|
||||||
Question struct {
|
Question struct {
|
||||||
Q string
|
Q string
|
||||||
|
Clues []string
|
||||||
Tags []string
|
Tags []string
|
||||||
}
|
}
|
||||||
Answer struct {
|
Answer struct {
|
||||||
|
|
@ -55,8 +57,25 @@ func Main() error {
|
||||||
}
|
}
|
||||||
question := db.Question(q)
|
question := db.Question(q)
|
||||||
fmt.Printf("> Q: %s\n", question.Q)
|
fmt.Printf("> Q: %s\n", question.Q)
|
||||||
fmt.Printf("> %+v\n\t", question.Tags)
|
fmt.Printf("> %+v\n", question.Tags)
|
||||||
response := readline()
|
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 != "" {
|
if lastAnswer := db.Answer(db.LastAnswer(user, q).A); lastAnswer.A != "" {
|
||||||
fmt.Printf("> Last time, you responded:\n\t%s\n", lastAnswer.A)
|
fmt.Printf("> Last time, you responded:\n\t%s\n", lastAnswer.A)
|
||||||
}
|
}
|
||||||
|
|
@ -74,9 +93,10 @@ func Main() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readline() string {
|
func readline() string {
|
||||||
|
fmt.Printf("\t")
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
text, _ := reader.ReadString('\n')
|
text, _ := reader.ReadString('\n')
|
||||||
return text
|
return strings.TrimSpace(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDB() (DB, error) {
|
func NewDB() (DB, error) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ knowledge:
|
||||||
questions:
|
questions:
|
||||||
uuid1:
|
uuid1:
|
||||||
q: whats a fieldset
|
q: whats a fieldset
|
||||||
|
clues:
|
||||||
|
- clue1 of 2
|
||||||
|
- clue2 of 2
|
||||||
tags:
|
tags:
|
||||||
- ops
|
- ops
|
||||||
- data-platform
|
- data-platform
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue