Have -C look in the usual directories (not always absolute path)

This commit is contained in:
Sean E. Russell 2020-04-29 12:07:37 -05:00
parent 8d2dfce31c
commit 02a2792424
4 changed files with 10 additions and 2 deletions

View File

@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Log files stored in \$XDG_CACHE_HOME; DATA, CONFIG, CACHE, and RUNTIME are the only directories specified by the FreeDesktop spec.
- Extensions are now built with a build tool; this is an interim solution until issues with the Go plugin API are resolved.
- Command line help text is cleaned up.
- Version bump of gopsutil
### Removed

View File

@ -74,7 +74,12 @@ func (conf *Config) Load() error {
}
var err error
if _, err = os.Stat(conf.ConfigFile); os.IsNotExist(err) {
return nil
// Check for the file in the usual suspects
folder := conf.ConfigDir.QueryFolderContainsFile(conf.ConfigFile)
if folder == nil {
return nil
}
conf.ConfigFile = filepath.Join(folder.Path, conf.ConfigFile)
}
if in, err = ioutil.ReadFile(conf.ConfigFile); err != nil {
return err

2
go.mod
View File

@ -10,7 +10,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/prometheus/client_golang v1.4.1
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
github.com/shirou/gopsutil v2.18.11+incompatible
github.com/shirou/gopsutil v2.20.3+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/stretchr/testify v1.4.0
github.com/xxxserxxx/iSMC v1.0.1

2
go.sum
View File

@ -97,6 +97,8 @@ github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
github.com/shirou/gopsutil v2.18.11+incompatible h1:PMFTKnFTr/YTRW5rbLK4vWALV3a+IGXse5nvhSjztmg=
github.com/shirou/gopsutil v2.18.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.20.3+incompatible h1:0JVooMPsT7A7HqEYdydp/OfjSOYSjhXV7w1hkKj/NPQ=
github.com/shirou/gopsutil v2.20.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=