1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Improvements and CHANGELOG for #651

This commit is contained in:
Andrey Nering
2022-02-19 19:31:27 -03:00
parent cfb665310e
commit b323531dd5
8 changed files with 103 additions and 100 deletions

View File

@@ -1,9 +1,11 @@
package output
import (
"fmt"
"io"
)
"github.com/go-task/task/v3/taskfile"
)
// Templater executes a template engine.
// It is provided by the templater.Templater package.
@@ -15,3 +17,33 @@ type Templater interface {
type Output interface {
WrapWriter(w io.Writer, prefix string, tmpl Templater) io.Writer
}
// Build the Output for the requested taskfile.Output.
func BuildFor(o *taskfile.Output) (Output, error) {
switch o.Name {
case "interleaved", "":
if err := checkOutputGroupUnset(o); err != nil {
return nil, err
}
return Interleaved{}, nil
case "group":
return Group{
Begin: o.Group.Begin,
End: o.Group.End,
}, nil
case "prefixed":
if err := checkOutputGroupUnset(o); err != nil {
return nil, err
}
return Prefixed{}, nil
default:
return nil, fmt.Errorf(`task: output style %q not recognized`, o.Name)
}
}
func checkOutputGroupUnset(o *taskfile.Output) error {
if o.Group.IsSet() {
return fmt.Errorf("task: output style %q does not support the group begin/end parameter", o.Name)
}
return nil
}