feat: fix handling of ~
in default config file path
This commit is contained in:
parent
e14492a01c
commit
7120877242
1 changed files with 6 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue