2021-02-13 08:39:05 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-02-21 17:37:15 -08:00
|
|
|
"flag"
|
2021-02-13 08:39:05 -08:00
|
|
|
"fmt"
|
2021-02-21 17:37:15 -08:00
|
|
|
"os"
|
2021-02-13 08:39:05 -08:00
|
|
|
|
2021-02-13 08:52:59 -08:00
|
|
|
"github.com/zorchenhimer/hacker-quotes"
|
2021-02-13 08:39:05 -08:00
|
|
|
"github.com/zorchenhimer/hacker-quotes/database"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-02-21 17:37:15 -08:00
|
|
|
var count int
|
|
|
|
var format string
|
2021-02-13 08:39:05 -08:00
|
|
|
|
2021-02-21 17:37:15 -08:00
|
|
|
flag.IntVar(&count, "c", 1, "Number of sentences to generate")
|
|
|
|
flag.StringVar(&format, "f", "", "Custom format to use when generating sentences")
|
|
|
|
flag.Parse()
|
2021-02-13 08:39:05 -08:00
|
|
|
|
|
|
|
db, err := database.New("sqlite", "file:db.sqlite?mode=memory")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2021-02-17 06:08:41 -08:00
|
|
|
hq, err := hacker.NewEnglish(db)
|
2021-02-13 08:39:05 -08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = hq.InitData("word_lists.json")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2021-02-21 17:37:15 -08:00
|
|
|
fmt.Println("")
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
var sentence string
|
|
|
|
var err error
|
|
|
|
|
|
|
|
if format != "" {
|
|
|
|
sentence, err = hq.HackThis(format)
|
|
|
|
} else {
|
|
|
|
sentence, err = hq.Hack()
|
|
|
|
}
|
2021-02-13 08:39:05 -08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2021-02-21 17:37:15 -08:00
|
|
|
fmt.Println(">>", sentence, "<<")
|
2021-02-13 08:39:05 -08:00
|
|
|
}
|
|
|
|
}
|