Commit 34f5709242

34f57092423909f1b7dfb773df32882f62aaa1f2

parent: d8d078535a

Unsigned

Wraient <wraient.911@gmail.com> · 2025-07-23 17:50 UTC

Mod: Make functions public

Layout: unified · split

internal/config.go +10 −10
@@ -110,7 +110,7 @@ func LoadConfig(configPath string) (CurdConfig, error) {
110110 }
111111
112112 // Load the config from file
113 configMap, err := loadConfigFromFile(configPath)
113 configMap, err := LoadConfigFromFile(configPath)
114114 if err != nil {
115115 return CurdConfig{}, fmt.Errorf("error loading config file: %v", err)
116116 }
@@ -133,7 +133,7 @@ func LoadConfig(configPath string) (CurdConfig, error) {
133133
134134 // Write updated config back to file only if AddMissingOptions is true
135135 if addMissing && updated {
136 if err := saveConfigToFile(configPath, configMap); err != nil {
136 if err := SaveConfigToFile(configPath, configMap); err != nil {
137137 return CurdConfig{}, fmt.Errorf("error saving updated config file: %v", err)
138138 }
139139 }
@@ -144,7 +144,7 @@ func LoadConfig(configPath string) (CurdConfig, error) {
144144 }
145145
146146 // Populate the CurdConfig struct from the config map
147 config := populateConfig(configMap)
147 config := PopulateConfig(configMap)
148148
149149 return config, nil
150150}
@@ -249,8 +249,8 @@ func ChangeToken(config *CurdConfig, user *User) {
249249 WriteTokenToFile(user.Token, tokenPath)
250250}
251251
252// Load config file from disk into a map (key=value format)
253func loadConfigFromFile(path string) (map[string]string, error) {
252// LoadConfigFromFile loads config file from disk into a map (key=value format)
253func LoadConfigFromFile(path string) (map[string]string, error) {
254254 file, err := os.Open(path)
255255 if err != nil {
256256 return nil, err
@@ -281,8 +281,8 @@ func loadConfigFromFile(path string) (map[string]string, error) {
281281 return configMap, nil
282282}
283283
284// Save updated config map to file in key=value format
285func saveConfigToFile(path string, configMap map[string]string) error {
284// SaveConfigToFile saves updated config map to file in key=value format
285func SaveConfigToFile(path string, configMap map[string]string) error {
286286 file, err := os.Create(path)
287287 if err != nil {
288288 return err
@@ -299,8 +299,8 @@ func saveConfigToFile(path string, configMap map[string]string) error {
299299 return writer.Flush()
300300}
301301
302// Populate the CurdConfig struct from a map
303func populateConfig(configMap map[string]string) CurdConfig {
302// PopulateConfig populates the CurdConfig struct from a map
303func PopulateConfig(configMap map[string]string) CurdConfig {
304304 config := CurdConfig{}
305305 configValue := reflect.ValueOf(&config).Elem()
306306
@@ -334,7 +334,7 @@ func populateConfig(configMap map[string]string) CurdConfig {
334334 return config
335335}
336336
337func getOrderedCategories(userCurdConfig *CurdConfig) map[string]string {
337func getOrderedCategories(userCurdConfig *CurdConfig) []SelectionOption {
338338 // Define the default categories and their labels
339339 defaultOrder := []string{"CURRENT", "ALL", "UNTRACKED", "UPDATE", "CONTINUE_LAST"}
340340 defaultLabels := map[string]string{