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

Method ListTaskNames

help.go:112–138  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

110// Only tasks with a non-empty description are printed if allTasks is false.
111// Otherwise, all task names are printed.
112func (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
140func (e *Executor) ToEditorOutput(tasks []*ast.Task, noStatus bool, nested bool) (*editors.Namespace, error) {
141 var g errgroup.Group

Callers 1

runFunction · 0.95

Calls 2

LenMethod · 0.45
ValuesMethod · 0.45

Tested by

no test coverage detected