Skip to content

Commit

Permalink
refactor: bubble errors from ListTaskNames
Browse files Browse the repository at this point in the history
  • Loading branch information
pd93 authored and andreynering committed Feb 22, 2024
1 parent ba81181 commit 07a0b89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cmd/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ func run() error {
}

if (listOptions.ShouldListTasks()) && flags.silent {
e.ListTaskNames(flags.listAll)
return nil
return e.ListTaskNames(flags.listAll)
}

if err := e.Setup(); err != nil {
Expand Down
7 changes: 3 additions & 4 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"os"
"strings"
"text/tabwriter"
Expand Down Expand Up @@ -121,16 +120,15 @@ func (e *Executor) ListTasks(o ListOptions) (bool, error) {
// ListTaskNames prints only the task names in a Taskfile.
// Only tasks with a non-empty description are printed if allTasks is false.
// Otherwise, all task names are printed.
func (e *Executor) ListTaskNames(allTasks bool) {
func (e *Executor) ListTaskNames(allTasks bool) error {
// if called from cmd/task.go, e.Logger has not yet been initialized
if e.Logger == nil {
e.setupLogger()
}
// if called from cmd/task.go, e.Taskfile has not yet been parsed
if e.Taskfile == nil {
if err := e.readTaskfile(); err != nil {
log.Fatal(err)
return
return err
}
}
// use stdout if no output defined
Expand Down Expand Up @@ -161,6 +159,7 @@ func (e *Executor) ListTaskNames(allTasks bool) {
for _, t := range taskNames {
fmt.Fprintln(w, t)
}
return nil
}

func (e *Executor) ToEditorOutput(tasks []*ast.Task, noStatus bool) (*editors.Taskfile, error) {
Expand Down

0 comments on commit 07a0b89

Please sign in to comment.