1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

refactor: Create executor struct to get rid of global variables

Maybe eventually help on #17
This commit is contained in:
Andrey Nering
2017-06-04 16:02:04 -03:00
parent c40148a52e
commit f98bf6c4b1
9 changed files with 137 additions and 109 deletions

10
help.go
View File

@@ -7,8 +7,8 @@ import (
"text/tabwriter"
)
func printExistingTasksHelp() {
tasks := tasksWithDesc()
func (e *Executor) printExistingTasksHelp() {
tasks := e.tasksWithDesc()
if len(tasks) == 0 {
return
}
@@ -17,13 +17,13 @@ func printExistingTasksHelp() {
// Format in tab-separated columns with a tab stop of 8.
w := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0)
for _, task := range tasks {
fmt.Fprintln(w, fmt.Sprintf("- %s:\t%s", task, Tasks[task].Desc))
fmt.Fprintln(w, fmt.Sprintf("- %s:\t%s", task, e.Tasks[task].Desc))
}
w.Flush()
}
func tasksWithDesc() (tasks []string) {
for name, task := range Tasks {
func (e *Executor) tasksWithDesc() (tasks []string) {
for name, task := range e.Tasks {
if task.Desc != "" {
tasks = append(tasks, name)
}