1
0
mirror of https://github.com/go-task/task.git synced 2025-04-15 11:56:34 +02:00
task/help.go
Andrey Nering e065dcb816 Revert "list: print message with there's no task with description"
This reverts commit 2508bed36353f1056b13cd16096b6351ec44d8aa.

I still want to do this, but since it break some existing Taskfiles,
let's give a little more thought on this first.
2017-11-19 18:12:16 -02:00

34 lines
679 B
Go

package task
import (
"fmt"
"sort"
"text/tabwriter"
)
// PrintTasksHelp prints help os tasks that have a description
func (e *Executor) PrintTasksHelp() {
tasks := e.tasksWithDesc()
if len(tasks) == 0 {
return
}
e.outf("Available tasks for this project:")
// Format in tab-separated columns with a tab stop of 8.
w := tabwriter.NewWriter(e.Stdout, 0, 8, 0, '\t', 0)
for _, task := range tasks {
fmt.Fprintln(w, fmt.Sprintf("* %s: \t%s", task, e.Tasks[task].Desc))
}
w.Flush()
}
func (e *Executor) tasksWithDesc() (tasks []string) {
for name, task := range e.Tasks {
if task.Desc != "" {
tasks = append(tasks, name)
}
}
sort.Strings(tasks)
return
}