fix: Handle implicit relative path for config

Fixes #117
This commit is contained in:
Anton Ovchinnikov
2025-09-07 15:58:09 +02:00
parent 9963f9df2d
commit ec2787c99c
2 changed files with 84 additions and 0 deletions
+4
View File
@@ -53,6 +53,10 @@ func (c *Config) Read() error {
func (c *Config) Save() error {
dir, _ := filepath.Split(c.path)
// If dir is empty (e.g., when path is just a filename), use current directory
if dir == "" {
dir = "."
}
if err := os.MkdirAll(dir, 0o700); err != nil {
return fmt.Errorf("create config directory '%s': %w", dir, err)
}