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

Function writeConfigFile

apps/cli/internal/cli/project_init.go:634–654  ·  view source on GitHub ↗

writeConfigFile writes .taskmd.yaml to the project root.

(root, taskDirPath string, idStrategy idStrategyConfig, quiet bool)

Source from the content-addressed store, hash-verified

632
633// writeConfigFile writes .taskmd.yaml to the project root.
634func writeConfigFile(root, taskDirPath string, idStrategy idStrategyConfig, quiet bool) (created bool, err error) {
635 configPath := filepath.Join(root, configFilename)
636
637 if !projectInitForce {
638 if _, err := os.Stat(configPath); err == nil {
639 if !quiet {
640 abs, _ := filepath.Abs(configPath)
641 fmt.Fprintf(os.Stderr, "Skipped %s (already exists, use --force to overwrite)\n", abs)
642 }
643 return false, nil
644 }
645 }
646
647 content := fmt.Sprintf("dir: %s\n", taskDirPath)
648 content += buildIDConfigYAML(idStrategy)
649
650 if err := os.WriteFile(configPath, []byte(content), 0644); err != nil {
651 return false, fmt.Errorf("failed to write %s: %w", configFilename, err)
652 }
653 return true, nil
654}
655
656// buildIDConfigYAML returns the id: section for .taskmd.yaml.
657// Returns empty string for the default sequential strategy.

Callers 1

writeProjectFilesFunction · 0.85

Calls 1

buildIDConfigYAMLFunction · 0.85

Tested by

no test coverage detected