Add GRUS_PRINT_PATH variable & bump version to v0.2.1
This commit is contained in:
parent
9fc666f608
commit
cd94bf2bdd
14
README.org
14
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
|
||||
|
|
15
grus.go
15
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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user