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

Method GetTask

task.go:523–550  ·  view source on GitHub ↗

GetTask will return the task with the name matching the given call from the taskfile. If no task is found, it will search for tasks with a matching alias. If multiple tasks contain the same alias or no matches are found an error is returned.

(call *Call)

Source from the content-addressed store, hash-verified

521// If no task is found, it will search for tasks with a matching alias.
522// If multiple tasks contain the same alias or no matches are found an error is returned.
523func (e *Executor) GetTask(call *Call) (*ast.Task, error) {
524 // Search for a matching task
525 matchingTasks, err := e.FindMatchingTasks(call)
526 if err != nil {
527 return nil, err
528 }
529
530 if len(matchingTasks) > 0 {
531 if call.Vars == nil {
532 call.Vars = ast.NewVars()
533 }
534 call.Vars.Set("MATCH", ast.Var{Value: matchingTasks[0].Wildcards})
535 return matchingTasks[0].Task, nil
536 }
537
538 // If we found no tasks
539 didYouMean := ""
540 if !e.DisableFuzzy {
541 e.fuzzyModelOnce.Do(e.setupFuzzyModel)
542 if e.fuzzyModel != nil {
543 didYouMean = e.fuzzyModel.SpellCheck(call.Task)
544 }
545 }
546 return nil, &errors.TaskNotFoundError{
547 TaskName: call.Task,
548 DidYouMean: didYouMean,
549 }
550}
551
552type FilterFunc func(task *ast.Task) bool
553

Callers 6

TestSilenceFunction · 0.95
compiledTaskMethod · 0.95
watchTasksMethod · 0.95
RunMethod · 0.95

Calls 3

FindMatchingTasksMethod · 0.95
NewVarsFunction · 0.92
SetMethod · 0.45

Tested by 1

TestSilenceFunction · 0.76