feat: fix handling of ~ in default config file path

This commit is contained in:
Sebastian Mark 2024-10-23 20:22:43 +02:00
parent e14492a01c
commit 7120877242

View file

@ -5,10 +5,16 @@ import (
"github.com/charmbracelet/log"
"gopkg.in/yaml.v2"
"os"
"path/filepath"
"strings"
)
func ParseConfig(filename string) models.ConfigFile {
var config models.ConfigFile
if strings.HasPrefix(filename, "~/") {
dirname, _ := os.UserHomeDir()
filename = filepath.Join(dirname, filename[2:])
}
yamlFile, err := os.ReadFile(filename)
if err != nil {
log.Error("Error opening config file!", "reason", err)