This commit is contained in:
2025-07-20 11:32:41 -07:00
parent d133ae6b29
commit 89f954eec9
2 changed files with 16 additions and 1 deletions

View File

@ -100,14 +100,16 @@ func setupConfig(rerun bool) (*Config, error) {
file, err := os.Create(cfgPath)
if err != nil {
file.Close()
return nil, fmt.Errorf("unable to create config file: %v", err)
}
defer file.Close()
encoder := toml.NewEncoder(file)
if err = encoder.Encode(newConfig); err != nil {
file.Close()
return nil, fmt.Errorf("unable to encode config file: %v", err)
}
file.Close()
fmt.Printf("Created new config at %s\n\n", cfgPath)
}
@ -117,6 +119,18 @@ func setupConfig(rerun bool) (*Config, error) {
return nil, err
}
// Rewrite config file with any new defaults
file, err := os.Create(cfgPath)
if err != nil {
return nil, fmt.Errorf("unable to config file: %v", err)
}
defer file.Close()
encoder := toml.NewEncoder(file)
if err = encoder.Encode(newConfig); err != nil {
return nil, fmt.Errorf("unable to encode config file: %v", err)
}
return &newConfig, nil
}