MCPcopy
hub / github.com/go-task/task / ToEditorOutput

Method ToEditorOutput

help.go:140–200  ·  view source on GitHub ↗
(tasks []*ast.Task, noStatus bool, nested bool)

Source from the content-addressed store, hash-verified

138}
139
140func (e *Executor) ToEditorOutput(tasks []*ast.Task, noStatus bool, nested bool) (*editors.Namespace, error) {
141 var g errgroup.Group
142 editorTasks := make([]editors.Task, len(tasks))
143
144 // Look over each task in parallel and turn it into an editor task
145 for i := range tasks {
146 g.Go(func() error {
147 editorTask := editors.NewTask(tasks[i])
148
149 if noStatus {
150 editorTasks[i] = editorTask
151 return nil
152 }
153
154 // Get the fingerprinting method to use
155 method := e.Taskfile.Method
156 if tasks[i].Method != "" {
157 method = tasks[i].Method
158 }
159 upToDate, err := fingerprint.IsTaskUpToDate(context.Background(), tasks[i],
160 fingerprint.WithMethod(method),
161 fingerprint.WithTempDir(e.TempDir.Fingerprint),
162 fingerprint.WithDry(e.Dry),
163 fingerprint.WithLogger(e.Logger),
164 )
165 if err != nil {
166 return err
167 }
168
169 editorTask.UpToDate = &upToDate
170 editorTasks[i] = editorTask
171 return nil
172 })
173 }
174 if err := g.Wait(); err != nil {
175 return nil, err
176 }
177
178 // Create the root namespace
179 var tasksLen int
180 if !nested {
181 tasksLen = len(editorTasks)
182 }
183 rootNamespace := &editors.Namespace{
184 Tasks: make([]editors.Task, tasksLen),
185 Location: e.Taskfile.Location,
186 }
187
188 // Recursively add namespaces to the root namespace or if nesting is
189 // disabled add them all to the root namespace
190 for i, task := range editorTasks {
191 taskNamespacePath := strings.Split(task.Task, ast.NamespaceSeparator)
192 if nested {
193 rootNamespace.AddNamespace(taskNamespacePath, task)
194 } else {
195 rootNamespace.Tasks[i] = task
196 }
197 }

Callers 1

ListTasksMethod · 0.95

Calls 7

AddNamespaceMethod · 0.95
NewTaskFunction · 0.92
IsTaskUpToDateFunction · 0.92
WithMethodFunction · 0.92
WithTempDirFunction · 0.92
WithDryFunction · 0.92
WithLoggerFunction · 0.92

Tested by

no test coverage detected