ListTaskNames prints only the task names in a Taskfile. Only tasks with a non-empty description are printed if allTasks is false. Otherwise, all task names are printed.
(allTasks bool)
| 110 | // Only tasks with a non-empty description are printed if allTasks is false. |
| 111 | // Otherwise, all task names are printed. |
| 112 | func (e *Executor) ListTaskNames(allTasks bool) error { |
| 113 | // use stdout if no output defined |
| 114 | var w io.Writer = os.Stdout |
| 115 | if e.Stdout != nil { |
| 116 | w = e.Stdout |
| 117 | } |
| 118 | |
| 119 | // Sort the tasks |
| 120 | if e.TaskSorter == nil { |
| 121 | e.TaskSorter = sort.AlphaNumericWithRootTasksFirst |
| 122 | } |
| 123 | |
| 124 | // Create a list of task names |
| 125 | taskNames := make([]string, 0, e.Taskfile.Tasks.Len()) |
| 126 | for task := range e.Taskfile.Tasks.Values(e.TaskSorter) { |
| 127 | if (allTasks || task.Desc != "") && !task.Internal { |
| 128 | taskNames = append(taskNames, strings.TrimRight(task.Task, ":")) |
| 129 | for _, alias := range task.Aliases { |
| 130 | taskNames = append(taskNames, strings.TrimRight(alias, ":")) |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | for _, t := range taskNames { |
| 135 | fmt.Fprintln(w, t) |
| 136 | } |
| 137 | return nil |
| 138 | } |
| 139 | |
| 140 | func (e *Executor) ToEditorOutput(tasks []*ast.Task, noStatus bool, nested bool) (*editors.Namespace, error) { |
| 141 | var g errgroup.Group |