Ignore error if default config file does not exist

This commit is contained in:
Manuel Rüger 2023-04-25 22:45:15 +02:00
parent 2f44bcb6be
commit 4c3d417725

View File

@ -154,7 +154,11 @@ func main() {
filePath := context.String("config") filePath := context.String("config")
return altsrc.NewTomlSourceFromFile(filePath) return altsrc.NewTomlSourceFromFile(filePath)
} else { } else {
// Fall back to default if config is unset // Fall back to default if config is unset and path exists
_, err := os.Stat(filepath.Join(os.Getenv("HOME"), ".config/mark"))
if os.IsNotExist(err) {
return &altsrc.MapInputSource{}, nil
}
return altsrc.NewTomlSourceFromFile(filepath.Join(os.Getenv("HOME"), ".config/mark")) return altsrc.NewTomlSourceFromFile(filepath.Join(os.Getenv("HOME"), ".config/mark"))
} }
}), }),