2017-03-19 20:18:18 +02:00
|
|
|
package task
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sort"
|
|
|
|
"text/tabwriter"
|
|
|
|
)
|
|
|
|
|
2017-06-04 21:02:04 +02:00
|
|
|
func (e *Executor) printExistingTasksHelp() {
|
|
|
|
tasks := e.tasksWithDesc()
|
2017-03-19 20:18:18 +02:00
|
|
|
if len(tasks) == 0 {
|
|
|
|
return
|
|
|
|
}
|
2017-07-01 20:05:51 +02:00
|
|
|
e.println("Available tasks for this project:")
|
2017-03-19 20:18:18 +02:00
|
|
|
|
|
|
|
// Format in tab-separated columns with a tab stop of 8.
|
2017-07-01 20:05:51 +02:00
|
|
|
w := tabwriter.NewWriter(e.Stdout, 0, 8, 0, '\t', 0)
|
2017-03-19 20:18:18 +02:00
|
|
|
for _, task := range tasks {
|
2017-06-04 21:02:04 +02:00
|
|
|
fmt.Fprintln(w, fmt.Sprintf("- %s:\t%s", task, e.Tasks[task].Desc))
|
2017-03-19 20:18:18 +02:00
|
|
|
}
|
|
|
|
w.Flush()
|
|
|
|
}
|
|
|
|
|
2017-06-04 21:02:04 +02:00
|
|
|
func (e *Executor) tasksWithDesc() (tasks []string) {
|
|
|
|
for name, task := range e.Tasks {
|
2017-03-19 20:18:18 +02:00
|
|
|
if task.Desc != "" {
|
|
|
|
tasks = append(tasks, name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sort.Strings(tasks)
|
|
|
|
return
|
|
|
|
}
|