Commit 34f5709242
Unsigned
Layout: unified · split
internal/config.go +10 −10
| @@ -110,7 +110,7 @@ func LoadConfig(configPath string) (CurdConfig, error) { | ||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Load the config from file |
| 113 | configMap, err := loadConfigFromFile(configPath) | |
| 113 | configMap, err := LoadConfigFromFile(configPath) | |
| 114 | 114 | if err != nil { |
| 115 | 115 | return CurdConfig{}, fmt.Errorf("error loading config file: %v", err) |
| 116 | 116 | } |
| @@ -133,7 +133,7 @@ func LoadConfig(configPath string) (CurdConfig, error) { | ||
| 133 | 133 | |
| 134 | 134 | // Write updated config back to file only if AddMissingOptions is true |
| 135 | 135 | if addMissing && updated { |
| 136 | if err := saveConfigToFile(configPath, configMap); err != nil { | |
| 136 | if err := SaveConfigToFile(configPath, configMap); err != nil { | |
| 137 | 137 | return CurdConfig{}, fmt.Errorf("error saving updated config file: %v", err) |
| 138 | 138 | } |
| 139 | 139 | } |
| @@ -144,7 +144,7 @@ func LoadConfig(configPath string) (CurdConfig, error) { | ||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Populate the CurdConfig struct from the config map |
| 147 | config := populateConfig(configMap) | |
| 147 | config := PopulateConfig(configMap) | |
| 148 | 148 | |
| 149 | 149 | return config, nil |
| 150 | 150 | } |
| @@ -249,8 +249,8 @@ func ChangeToken(config *CurdConfig, user *User) { | ||
| 249 | 249 | WriteTokenToFile(user.Token, tokenPath) |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | // Load config file from disk into a map (key=value format) | |
| 253 | func loadConfigFromFile(path string) (map[string]string, error) { | |
| 252 | // LoadConfigFromFile loads config file from disk into a map (key=value format) | |
| 253 | func LoadConfigFromFile(path string) (map[string]string, error) { | |
| 254 | 254 | file, err := os.Open(path) |
| 255 | 255 | if err != nil { |
| 256 | 256 | return nil, err |
| @@ -281,8 +281,8 @@ func loadConfigFromFile(path string) (map[string]string, error) { | ||
| 281 | 281 | return configMap, nil |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | // Save updated config map to file in key=value format | |
| 285 | func saveConfigToFile(path string, configMap map[string]string) error { | |
| 284 | // SaveConfigToFile saves updated config map to file in key=value format | |
| 285 | func SaveConfigToFile(path string, configMap map[string]string) error { | |
| 286 | 286 | file, err := os.Create(path) |
| 287 | 287 | if err != nil { |
| 288 | 288 | return err |
| @@ -299,8 +299,8 @@ func saveConfigToFile(path string, configMap map[string]string) error { | ||
| 299 | 299 | return writer.Flush() |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | // Populate the CurdConfig struct from a map | |
| 303 | func populateConfig(configMap map[string]string) CurdConfig { | |
| 302 | // PopulateConfig populates the CurdConfig struct from a map | |
| 303 | func PopulateConfig(configMap map[string]string) CurdConfig { | |
| 304 | 304 | config := CurdConfig{} |
| 305 | 305 | configValue := reflect.ValueOf(&config).Elem() |
| 306 | 306 | |
| @@ -334,7 +334,7 @@ func populateConfig(configMap map[string]string) CurdConfig { | ||
| 334 | 334 | return config |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | func getOrderedCategories(userCurdConfig *CurdConfig) map[string]string { | |
| 337 | func getOrderedCategories(userCurdConfig *CurdConfig) []SelectionOption { | |
| 338 | 338 | // Define the default categories and their labels |
| 339 | 339 | defaultOrder := []string{"CURRENT", "ALL", "UNTRACKED", "UPDATE", "CONTINUE_LAST"} |
| 340 | 340 | defaultLabels := map[string]string{ |