mirror of
https://github.com/gotify/cli.git
synced 2024-01-28 15:20:39 +03:00
don't exit when current user is unknown (#14)
This commit is contained in:
@@ -4,25 +4,17 @@ import (
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/gotify/cli/utils"
|
||||
)
|
||||
|
||||
func userDir() string {
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
utils.Exit1With(err)
|
||||
}
|
||||
return usr.HomeDir
|
||||
}
|
||||
func GetLocations() (res []string) {
|
||||
res = append(res, "./cli.json")
|
||||
|
||||
func GetLocations() []string {
|
||||
inUserDir := filepath.Join(userDir(), ".gotify", "cli.json")
|
||||
etcPath := "/etc/gotify/cli.json"
|
||||
relativePath := "./cli.json"
|
||||
if runtime.GOOS == "windows" {
|
||||
return []string{relativePath, inUserDir}
|
||||
} else {
|
||||
return []string{relativePath, inUserDir, etcPath}
|
||||
if usr, err := user.Current(); err != nil {
|
||||
res = append(res, filepath.Join(usr.HomeDir, ".gotify", "cli.json"))
|
||||
}
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
res = append(res, "/etc/gotify/cli.json")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user