1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

refactor: wrap PrintTasksHelp with arg-less signatures

provide exported methods for accessing PrintTasksHelp variants.
This commit is contained in:
Kevin Ard
2022-01-03 12:12:18 -05:00
parent 347c796662
commit 42702e81b3
4 changed files with 23 additions and 9 deletions

16
help.go
View File

@@ -15,7 +15,7 @@ import (
func (e *Executor) PrintTasksHelp(listAll bool) {
var tasks []*taskfile.Task
if listAll == true {
tasks = e.taskNames()
tasks = e.allTaskNames()
} else {
tasks = e.tasksWithDesc()
}
@@ -35,7 +35,7 @@ func (e *Executor) PrintTasksHelp(listAll bool) {
w.Flush()
}
func (e *Executor) taskNames() (tasks []*taskfile.Task) {
func (e *Executor) allTaskNames() (tasks []*taskfile.Task) {
tasks = make([]*taskfile.Task, 0, len(e.Taskfile.Tasks))
for _, task := range e.Taskfile.Tasks {
tasks = append(tasks, task)
@@ -58,3 +58,15 @@ func (e *Executor) tasksWithDesc() (tasks []*taskfile.Task) {
sort.Slice(tasks, func(i, j int) bool { return tasks[i].Task < tasks[j].Task })
return
}
// ListTasksWithDesc reports tasks that have a description spec.
func (e *Executor) ListTasksWithDesc() {
e.PrintTasksHelp(false)
return
}
// ListAllTasks reports all tasks, with or without a description spec.
func (e *Executor) ListAllTasks() {
e.PrintTasksHelp(true)
return
}