summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-04-08 15:41:58 +0530
committerAndinus <andinus@nand.sh>2020-04-08 15:43:11 +0530
commitcd94bf2bdd4da3a0e48386454916c4e7c23ae9ac (patch)
tree9d9d9f5a5dd1fe6cdd32034837a5e0f6a563f168
parent9fc666f608fd6e156ddc3d3a5b363f341d2fb1ac (diff)
downloadgrus-cd94bf2bdd4da3a0e48386454916c4e7c23ae9ac.tar.gz
Add GRUS_PRINT_PATH variable & bump version to v0.2.1 v0.2.1
-rw-r--r--README.org14
-rw-r--r--grus.go15
2 files changed, 24 insertions, 5 deletions
diff --git a/README.org b/README.org
index 909575d..7a32ef0 100644
--- a/README.org
+++ b/README.org
@@ -26,10 +26,13 @@ be changed with two environment variables documented below.
 *Note*: If grus couldn't unjumble the word with first dictionary then it'll search
 in next dictionary, search stops once the word gets unjumbled.
 
-| Environment variable | Explanation                | Non-default values |
-|----------------------+----------------------------+--------------------|
-| =GRUS_SEARCH_ALL=      | Search in all dictionaries | 1 / true           |
-| =GRUS_ANAGRAMS=        | Print all anagrams         | 1 / true           |
+| Environment variable      | Explanation                        |
+|---------------------------+------------------------------------|
+| =GRUS_SEARCH_ALL=           | Search in all dictionaries         |
+| =GRUS_ANAGRAMS=             | Print all anagrams                 |
+| =GRUS_PRINT_PATH= =(v0.2.1+)= | Print dictionary path before words |
+
+Set these environment variable to /1 / true/ to change behaviour.
 ** Default Dictionaries
 These files will be checked by default (in order).
 - =/usr/local/share/dict/words=
@@ -57,6 +60,9 @@ GRUS_SEARCH_ALL=1 grus word /path/to/dict1 /path/to/dict2
 
 # search for word in all dictionaries & print all anagrams
 GRUS_SEARCH_ALL=1 GRUS_ANAGRAMS=1 grus word
+
+# print path to dictionary
+GRUS_PRINT_PATH=1 grus word
 #+END_SRC
 * Installation
 ** Pre-built binaries
diff --git a/grus.go b/grus.go
index 7c17a98..f84d9a1 100644
--- a/grus.go
+++ b/grus.go
@@ -14,7 +14,7 @@ func grus() {
 		os.Exit(1)
 	}
 
-	version := "v0.2.0"
+	version := "v0.2.1"
 
 	if os.Args[1] == "version" {
 		fmt.Printf("Grus %s\n", version)
@@ -52,6 +52,14 @@ func grus() {
 		anagrams = true
 	}
 
+	// Check if user wants to print dictionary path.
+	printPath := false
+	printPathEnv := os.Getenv("GRUS_PRINT_PATH")
+	if printPathEnv == "true" ||
+		printPathEnv == "1" {
+		printPath = true
+	}
+
 	for _, dict := range dicts {
 		if _, err := os.Stat(dict); err != nil &&
 			!os.IsNotExist(err) {
@@ -66,6 +74,11 @@ func grus() {
 			continue
 		}
 
+		// Print path to dictionary if printPath is true.
+		if printPath {
+			fmt.Println(dict)
+		}
+
 		file, err := os.Open(dict)
 		panicOnErr(err)
 		defer file.Close()
main: updated' href='/akspecs/ranger/commit/ranger/__main__.py?id=3937f01085b05b486a597cd6865ca49a5af2a1e4'>3937f010 ^
d0008325 ^
e57c337d ^
2948ed45 ^
0128bee7 ^
20d28b94 ^
d0008325 ^



3937f010 ^



fa4fd0a1 ^



75013dc7 ^
0128bee7 ^

ea87d005 ^
3937f010 ^


d4e2dfe9 ^

d0008325 ^
0128bee7 ^
a049ec03 ^
d0008325 ^




0128bee7 ^
d0008325 ^





d0008325 ^




0128bee7 ^
d0008325 ^








0128bee7 ^
766a5b6a ^
d0008325 ^


524d95e1 ^

d0008325 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153