warnDuplicateIDs prints a warning to stderr if any duplicate IDs exist. Returns the duplicate map for callers that need it.
(tasks []*model.Task)
| 42 | // warnDuplicateIDs prints a warning to stderr if any duplicate IDs exist. |
| 43 | // Returns the duplicate map for callers that need it. |
| 44 | func warnDuplicateIDs(tasks []*model.Task) map[string][]string { |
| 45 | dupes := findAllDuplicateIDs(tasks) |
| 46 | if len(dupes) == 0 { |
| 47 | return dupes |
| 48 | } |
| 49 | |
| 50 | fmt.Fprintf(os.Stderr, "Warning: found duplicate task IDs:\n") |
| 51 | for id, paths := range dupes { |
| 52 | fmt.Fprintf(os.Stderr, " ID %q in %d files: %s\n", id, len(paths), strings.Join(paths, ", ")) |
| 53 | } |
| 54 | fmt.Fprintf(os.Stderr, "Run 'taskmd deduplicate' to fix.\n") |
| 55 | return dupes |
| 56 | } |
| 57 | |
| 58 | // formatDuplicatePaths formats task file paths as a bulleted list. |
| 59 | func formatDuplicatePaths(tasks []*model.Task) string { |