Skip to content

Commit 0bffd8c

Browse files
committed
fix(config): allow custom config file to work
1 parent 85edd0f commit 0bffd8c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/config/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ func (t *Toolsium) Configure(cfgFile string) {
2222
log.Debugf("Using custom cfgFile %v", cfgFile)
2323
// Use config file from the flag.
2424
t.Config.SetConfigFile(cfgFile)
25-
} else {
26-
// Search config in home directory with name ".toolsium" (without extension).
27-
t.ConfigureViper()
25+
t.SetConfigFileName(filepath.Base(cfgFile))
26+
t.SetConfigDir(filepath.Dir(cfgFile))
2827
}
28+
t.configureViper()
2929
// If a config file is found, read it in.
3030
if err := t.Config.ReadInConfig(); err == nil {
3131
log.Infof("Using config file: %v", t.Config.ConfigFileUsed())
@@ -84,8 +84,7 @@ func (t *Toolsium) GetConfigFilePath() string {
8484
}
8585

8686
// Configures viper based on the provided passed directory and uses default file type and name.
87-
func ConfigureViper() { t.ConfigureViper() }
88-
func (t *Toolsium) ConfigureViper() {
87+
func (t *Toolsium) configureViper() {
8988
t.Config.AddConfigPath(t.GetConfigDir())
9089
t.Config.SetConfigType(cfgFileType)
9190
t.Config.SetConfigName(t.GetConfigFileName())

0 commit comments

Comments
 (0)