Skip to content

Commit

Permalink
Add support for env:SCOOP, closes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
shilangyu committed Jan 21, 2021
1 parent 85153af commit 2981718
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ type match struct {

type matchMap = map[string][]match

// resolves the path to scoop folder
func scoopHome() (res string) {
if value, ok := os.LookupEnv("SCOOP"); ok {
res = value
} else {
var err error
res, err = os.UserHomeDir()
checkWith(err, "Could not determine home dir")

res += "\\scoop"
}

return
}

func main() {
args := parseArgs()

Expand All @@ -29,9 +44,7 @@ func main() {
}

// get buckets path
homeDir, err := os.UserHomeDir()
checkWith(err, "Could not determine home dir")
bucketsPath := homeDir + "\\scoop\\buckets"
bucketsPath := scoopHome() + "\\buckets"

// get specific buckets
buckets, err := ioutil.ReadDir(bucketsPath)
Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func checkWith(err error, msg string) {
if err != nil {
log.Fatal(msg)
log.Fatal(msg, " - ", err)
}
}

Expand Down

0 comments on commit 2981718

Please sign in to comment.