summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-04-06 23:55:06 +0530
committerAndinus <andinus@nand.sh>2020-04-06 23:55:06 +0530
commit0a6d510d2add0e46e890cc6fcac39d3080ba689b (patch)
treea45985a0e503ee3736336dc9361d013ed7026629
parent30f7ea8ddf1077ddc3bc289f56dff39c41258827 (diff)
downloadgrus-0a6d510d2add0e46e890cc6fcac39d3080ba689b.tar.gz
Print anagrams instead of single word
-rw-r--r--cmd/grus/grus.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd/grus/grus.go b/cmd/grus/grus.go
index a68db97..2e04de8 100644
--- a/cmd/grus/grus.go
+++ b/cmd/grus/grus.go
@@ -47,12 +47,14 @@ func grus() {
 	word := os.Args[1]
 	sorted := lexical.Sort(word)
 
-	out, err := search.Word(sorted, db)
+	anagrams, err := search.Anagrams(sorted, db)
 	if err == sql.ErrNoRows {
 		fmt.Println("Word not found in database.")
 		return
 	} else if err != nil {
 		log.Fatalf("grus: Search failed :: %s", err)
 	}
-	fmt.Println(out)
+	for _, w := range anagrams {
+		fmt.Println(w)
+	}
 }