Skip to content

Commit 0c81489

Browse files
Add support for xdg specification config file (#32)
1 parent 13b1341 commit 0c81489

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ OPTIONS:
141141

142142
Gotify-CLI will search the following paths for a config file:
143143
* `/etc/gotify/cli.json`
144+
* `$XDG_CONFIG_HOME/gotify/cli.json`
144145
* `~/.gotify/cli.json`
145146
* `./cli.json`
146147

config/locations.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ import (
44
"os/user"
55
"path/filepath"
66
"runtime"
7+
8+
"github.com/adrg/xdg"
79
)
810

911
func GetLocations() (res []string) {
1012
res = append(res, "./cli.json")
1113

14+
xdgPath, err := xdg.ConfigFile(filepath.Join("gotify", "cli.json"))
15+
if err == nil {
16+
res = append(res, xdgPath)
17+
}
18+
1219
if usr, err := user.Current(); err == nil {
1320
res = append(res, filepath.Join(usr.HomeDir, ".gotify", "cli.json"))
1421
}

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/gotify/cli/v2
22

33
require (
4+
github.com/adrg/xdg v0.2.1
45
github.com/go-openapi/analysis v0.19.0 // indirect
56
github.com/go-openapi/errors v0.19.0 // indirect
67
github.com/go-openapi/jsonpointer v0.19.0 // indirect
@@ -19,3 +20,5 @@ require (
1920
golang.org/x/sys v0.0.0-20190412213103-97732733099d // indirect
2021
gopkg.in/urfave/cli.v1 v1.20.0
2122
)
23+
24+
go 1.14

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
44
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
55
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
66
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
7+
github.com/adrg/xdg v0.2.1 h1:VSVdnH7cQ7V+B33qSJHTCRlNgra1607Q8PzEmnvb2Ic=
8+
github.com/adrg/xdg v0.2.1/go.mod h1:ZuOshBmzV4Ta+s23hdfFZnBsdzmoR3US0d7ErpqSbTQ=
79
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco=
810
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
911
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

0 commit comments

Comments
 (0)