MCPcopy Create free account
hub / github.com/driangle/taskmd / LoadConfig

Function LoadConfig

apps/cli/internal/sync/config.go:45–73  ·  view source on GitHub ↗

LoadConfig reads the project config from dir/.taskmd.yaml and returns the sync section.

(dir string)

Source from the content-addressed store, hash-verified

43
44// LoadConfig reads the project config from dir/.taskmd.yaml and returns the sync section.
45func LoadConfig(dir string) (*SyncConfig, error) {
46 path := filepath.Join(dir, configFileName)
47 data, err := os.ReadFile(path)
48 if err != nil {
49 return nil, fmt.Errorf("failed to read config %s: %w", configFileName, err)
50 }
51
52 var cfg Config
53 if err := yaml.Unmarshal(data, &cfg); err != nil {
54 return nil, fmt.Errorf("failed to parse config %s: %w", configFileName, err)
55 }
56
57 syncCfg := &cfg.Sync
58
59 if len(syncCfg.Sources) == 0 {
60 return nil, fmt.Errorf("no sync sources defined in %s", configFileName)
61 }
62
63 for i, s := range syncCfg.Sources {
64 if s.Name == "" {
65 return nil, fmt.Errorf("source at index %d has no name", i)
66 }
67 if s.OutputDir == "" {
68 return nil, fmt.Errorf("source %q has no output_dir", s.Name)
69 }
70 }
71
72 return syncCfg, nil
73}

Calls

no outgoing calls