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

Function runSet

apps/cli/internal/cli/set.go:104–164  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

102}
103
104func runSet(cmd *cobra.Command, args []string) error {
105 taskID, err := resolveSetTaskID(cmd, args)
106 if err != nil {
107 return err
108 }
109
110 req, err := buildSetRequest(cmd)
111 if err != nil {
112 return err
113 }
114
115 flags := GetGlobalFlags()
116 scanDir := ResolveScanDir(nil)
117
118 taskScanner := scanner.NewScanner(scanDir, flags.Verbose, flags.IgnoreDirs)
119 result, err := taskScanner.Scan()
120 if err != nil {
121 return fmt.Errorf("scan failed: %w", err)
122 }
123
124 debugLog("scan directory: %s", scanDir)
125 debugLog("found %d task(s)", len(result.Tasks))
126
127 task := findExactMatch(taskID, result.Tasks)
128 if task == nil {
129 return fmt.Errorf("task not found: %s", taskID)
130 }
131
132 if dupes := findDuplicatesByID(taskID, result.Tasks); len(dupes) > 1 {
133 return fmt.Errorf("refusing to modify task %s: found %d files with this ID\n%s\nRun 'taskmd deduplicate' to fix",
134 taskID, len(dupes), formatDuplicatePaths(dupes))
135 }
136
137 if req.Dependencies != nil {
138 if err := validateDependencies(task, *req.Dependencies, result.Tasks); err != nil {
139 return err
140 }
141 }
142
143 applyTerminalDateLogic(task, &req)
144
145 if err := runSetVerification(task, req); err != nil {
146 return err
147 }
148
149 changes := buildChangeLog(task, req)
150
151 if setDryRun {
152 printSetConfirmation(task, changes)
153 r := getRenderer()
154 fmt.Println("\n" + formatWarning("Dry run — no changes made.", r))
155 return nil
156 }
157
158 if err := taskfile.UpdateTaskFile(task.FilePath, req); err != nil {
159 return err
160 }
161

Callers 2

captureSetOutputWithArgsFunction · 0.85

Calls 15

ScanMethod · 0.95
resolveSetTaskIDFunction · 0.85
buildSetRequestFunction · 0.85
GetGlobalFlagsFunction · 0.85
ResolveScanDirFunction · 0.85
debugLogFunction · 0.85
findExactMatchFunction · 0.85
findDuplicatesByIDFunction · 0.85
formatDuplicatePathsFunction · 0.85
validateDependenciesFunction · 0.85
applyTerminalDateLogicFunction · 0.85
runSetVerificationFunction · 0.85

Tested by 2

captureSetOutputWithArgsFunction · 0.68