Skip to content

Commit 92ff713

Browse files
committed
Only use ~/.mctl.yml if it already exists
Otherwise use xdg which is smart about giving us the platform specific cache dir. See https://github.com/adrg/xdg#xdg-base-directory for values used.
1 parent 374b427 commit 92ff713

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/app/app.go

+13
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ func openConfig(path string) (*os.File, error) {
4848
}
4949

5050
path = filepath.Join(xdg.Home, ".mctl.yml")
51+
f, err := os.Open(path)
52+
if err != nil {
53+
return f, nil
54+
}
55+
if !errors.Is(err, os.ErrNotExist) {
56+
return nil, err
57+
}
58+
59+
path, err = xdg.ConfigFile("mctl/config.yaml")
60+
if err != nil {
61+
return nil, err
62+
}
63+
5164
return os.Open(path)
5265
}
5366

0 commit comments

Comments
 (0)