1
0
mirror of https://github.com/go-task/task.git synced 2025-01-04 03:48:02 +02:00

refactor: bubble errors from ListTaskNames

This commit is contained in:
Pete Davison 2024-02-19 21:15:51 +00:00 committed by Andrey Nering
parent ba81181eb7
commit 07a0b8938f
2 changed files with 4 additions and 6 deletions

View File

@ -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 {

View File

@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"os"
"strings"
"text/tabwriter"
@ -121,7 +120,7 @@ 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()
@ -129,8 +128,7 @@ func (e *Executor) ListTaskNames(allTasks bool) {
// 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
@ -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) {