Load reads the config from .chief/config.yaml. Returns Default() when the file doesn't exist (no error).
(baseDir string)
| 52 | // Load reads the config from .chief/config.yaml. |
| 53 | // Returns Default() when the file doesn't exist (no error). |
| 54 | func Load(baseDir string) (*Config, error) { |
| 55 | path := configPath(baseDir) |
| 56 | |
| 57 | data, err := os.ReadFile(path) |
| 58 | if err != nil { |
| 59 | if os.IsNotExist(err) { |
| 60 | return Default(), nil |
| 61 | } |
| 62 | return nil, err |
| 63 | } |
| 64 | |
| 65 | cfg := Default() |
| 66 | if err := yaml.Unmarshal(data, cfg); err != nil { |
| 67 | return nil, err |
| 68 | } |
| 69 | |
| 70 | return cfg, nil |
| 71 | } |
| 72 | |
| 73 | // Save writes the config to .chief/config.yaml. |
| 74 | func Save(baseDir string, cfg *Config) error { |