@@ -9,20 +9,32 @@ import (
9
9
"github.com/go-task/task/v3/taskfile"
10
10
)
11
11
12
- // PrintTasksHelp prints tasks' help.
13
- // Behavior is governed by listAll. When false, only tasks with descriptions are reported.
14
- // When true, all tasks are reported with descriptions shown where available.
15
- func (e * Executor ) PrintTasksHelp (listAll bool ) {
12
+ // ListTasksWithDesc reports tasks that have a description spec.
13
+ func (e * Executor ) ListTasksWithDesc () {
14
+ e .pringTasks (false )
15
+ return
16
+ }
17
+
18
+ // ListAllTasks reports all tasks, with or without a description spec.
19
+ func (e * Executor ) ListAllTasks () {
20
+ e .pringTasks (true )
21
+ return
22
+ }
23
+
24
+ func (e * Executor ) pringTasks (listAll bool ) {
16
25
var tasks []* taskfile.Task
17
- if listAll == true {
26
+ if listAll {
18
27
tasks = e .allTaskNames ()
19
28
} else {
20
29
tasks = e .tasksWithDesc ()
21
30
}
22
31
23
32
if len (tasks ) == 0 {
24
- // TODO: This message should be more informative. Maybe a hint to try -la for showing all?
25
- e .Logger .Outf (logger .Yellow , "task: No tasks with description available" )
33
+ if listAll {
34
+ e .Logger .Outf (logger .Yellow , "task: No tasks available" )
35
+ } else {
36
+ e .Logger .Outf (logger .Yellow , "task: No tasks with description available. Try --list-all to list all tasks" )
37
+ }
26
38
return
27
39
}
28
40
e .Logger .Outf (logger .Default , "task: Available tasks for this project:" )
@@ -58,15 +70,3 @@ func (e *Executor) tasksWithDesc() (tasks []*taskfile.Task) {
58
70
sort .Slice (tasks , func (i , j int ) bool { return tasks [i ].Task < tasks [j ].Task })
59
71
return
60
72
}
61
-
62
- // ListTasksWithDesc reports tasks that have a description spec.
63
- func (e * Executor ) ListTasksWithDesc () {
64
- e .PrintTasksHelp (false )
65
- return
66
- }
67
-
68
- // ListAllTasks reports all tasks, with or without a description spec.
69
- func (e * Executor ) ListAllTasks () {
70
- e .PrintTasksHelp (true )
71
- return
72
- }
0 commit comments