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:
10
help.go
10
help.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user