MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / loadConfigFile

Function loadConfigFile

internal/cli/config_cmd.go:285–303  ·  view source on GitHub ↗

--- legacy CAM-config helpers (operate on the file at --config) ---------

(path string)

Source from the content-addressed store, hash-verified

283// --- legacy CAM-config helpers (operate on the file at --config) ---------
284
285func loadConfigFile(path string) (map[string]any, error) {
286 data, err := os.ReadFile(path)
287 if err != nil {
288 return nil, fmt.Errorf("failed to read config %s: %w", path, err)
289 }
290 cfg := map[string]any{}
291 switch strings.ToLower(filepath.Ext(path)) {
292 case ".json":
293 err = json.Unmarshal(data, &cfg)
294 case ".toml":
295 err = toml.Unmarshal(data, &cfg)
296 default:
297 err = yaml.Unmarshal(data, &cfg)
298 }
299 if err != nil {
300 return nil, fmt.Errorf("failed to parse config %s: %w", path, err)
301 }
302 return cfg, nil
303}
304
305func writeConfigFile(path string, cfg map[string]any) error {
306 var data []byte

Callers 3

configValidateCommandMethod · 0.85
legacyUnsetConfigFunction · 0.85
legacyApplyValueFunction · 0.85

Calls 1

ReadFileMethod · 0.80

Tested by

no test coverage detected