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

Function WriteTaskFile

apps/cli/internal/sync/writer.go:14–30  ·  view source on GitHub ↗

WriteTaskFile creates a new task markdown file and returns the file path.

(dir, id string, mapped MappedTask, externalID, sourceName string)

Source from the content-addressed store, hash-verified

12
13// WriteTaskFile creates a new task markdown file and returns the file path.
14func WriteTaskFile(dir, id string, mapped MappedTask, externalID, sourceName string) (string, error) {
15 if err := os.MkdirAll(dir, 0755); err != nil {
16 return "", fmt.Errorf("failed to create output directory: %w", err)
17 }
18
19 s := slug.Slugify(mapped.Title)
20 filename := fmt.Sprintf("%s-%s.md", id, s)
21 path := filepath.Join(dir, filename)
22
23 content := renderTaskFile(id, mapped, externalID, sourceName)
24
25 if err := os.WriteFile(path, []byte(content), 0644); err != nil {
26 return "", fmt.Errorf("failed to write task file: %w", err)
27 }
28
29 return path, nil
30}
31
32// UpdateSyncedTaskFile updates an existing synced task file.
33func UpdateSyncedTaskFile(filePath string, mapped MappedTask) error {

Callers 3

createTaskMethod · 0.85
recreateMissingFileMethod · 0.85
importTaskFunction · 0.85

Calls 1

renderTaskFileFunction · 0.85

Tested by

no test coverage detected