diff --git a/internal/config/config.go b/internal/config/config.go index 66f9ecd..358f71b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -52,14 +52,10 @@ type config struct { } func configWithDefaults() (*config, error) { - homeDir, err := os.UserHomeDir() c := &config{} - if err != nil { - return c, err - } c.LogLevel = "warn" - c.OpengistHome = filepath.Join(homeDir, ".opengist") + c.OpengistHome = "" c.DBFilename = "opengist.db" c.SqliteJournalMode = "WAL" @@ -93,6 +89,15 @@ func InitConfig(configPath string) error { return err } + if c.OpengistHome == "" { + homeDir, err := os.UserHomeDir() + if err != nil { + return fmt.Errorf("opengist home directory is not set and current user home directory could not be determined; please specify the opengist home directory manually via the configuration") + } + + c.OpengistHome = filepath.Join(homeDir, ".opengist") + } + if err = checks(c); err != nil { return err }