2021-02-13 08:39:05 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"fmt"
|
|
|
|
|
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() {
|
|
|
|
fmt.Println("len(os.Args):", len(os.Args))
|
|
|
|
|
|
|
|
var count int = 1
|
|
|
|
if len(os.Args) == 2 {
|
|
|
|
fmt.Sscanf(os.Args[1], "%d", &count)
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
if count == 1 {
|
2021-02-14 13:49:11 -08:00
|
|
|
sentence, err := hq.Hack()
|
2021-02-13 08:39:05 -08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("\n>>", sentence, "<<\n")
|
|
|
|
} else {
|
|
|
|
fmt.Println("")
|
|
|
|
for i := 0; i < count; i++ {
|
2021-02-14 13:49:11 -08:00
|
|
|
sentence, err := hq.Hack()
|
2021-02-13 08:39:05 -08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
fmt.Println(">>", sentence, "<<")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|