summaryrefslogtreecommitdiffstats
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-0.2.1.tar.gz
Add GRUS_PRINT_PATH variable & bump version to v0.2.1v0.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()