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)
| 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. |
| 523 | func (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 | |
| 552 | type FilterFunc func(task *ast.Task) bool |
| 553 |