File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Task now supports printing begin and end messages when using the ` group `
6+ output mode, useful for grouping tasks in CI systems.
7+ [ Check out the documentation] ( http://taskfile.dev/#/usage?id=output-syntax ) for more information
8+ ([ #647 ] ( https://github.com/go-task/task/issues/647 ) , [ #651 ] ( https://github.com/go-task/task/pull/651 ) ).
59- Add ` Taskfile.dist.yml ` and ` Taskfile.dist.yaml ` to the supported file
6- name list. [ Check out the documentation for more information ] ( https://taskfile.dev/#/usage?id=supported-file-names ) .
10+ name list. [ Check out the documentation] ( https://taskfile.dev/#/usage?id=supported-file-names ) for more information
711 ([ #498 ] ( https://github.com/go-task/task/issues/498 ) , [ #666 ] ( https://github.com/go-task/task/pull/666 ) ).
812
913## v3.10.0 - 2022-01-04
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import (
1111 "strings"
1212 "syscall"
1313
14- outputpkg "github.com/go-task/task/v3/internal/output"
1514 "github.com/spf13/pflag"
1615 "mvdan.cc/sh/v3/syntax"
1716
@@ -73,7 +72,7 @@ func main() {
7372 concurrency int
7473 dir string
7574 entrypoint string
76- output outputpkg. Style
75+ output taskfile. Output
7776 color bool
7877 )
7978
Original file line number Diff line number Diff line change @@ -974,9 +974,10 @@ tasks:
974974 to run.
975975
976976When using the `group` output, you can optionally provide a templated message
977- to print at the start of the group. This can be useful for instructing CI
978- systems to group all of the output for a given task, such as with [GitHub
979- Actions' `::group::` command](https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines).
977+ to print at the start and end of the group. This can be useful for instructing
978+ CI systems to group all of the output for a given task, such as with
979+ [GitHub Actions' `::group::` command](https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines)
980+ or [Azure Pipelines](https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?expand=1&view=azure-devops&tabs=bash#formatting-commands).
980981
981982` ` ` yaml
982983version: '3'
Original file line number Diff line number Diff line change 11package output
22
33import (
4+ "fmt"
45 "io"
5- )
66
7+ "github.com/go-task/task/v3/taskfile"
8+ )
79
810// Templater executes a template engine.
911// It is provided by the templater.Templater package.
@@ -15,3 +17,33 @@ type Templater interface {
1517type Output interface {
1618 WrapWriter (w io.Writer , prefix string , tmpl Templater ) io.Writer
1719}
20+
21+ // Build the Output for the requested taskfile.Output.
22+ func BuildFor (o * taskfile.Output ) (Output , error ) {
23+ switch o .Name {
24+ case "interleaved" , "" :
25+ if err := checkOutputGroupUnset (o ); err != nil {
26+ return nil , err
27+ }
28+ return Interleaved {}, nil
29+ case "group" :
30+ return Group {
31+ Begin : o .Group .Begin ,
32+ End : o .Group .End ,
33+ }, nil
34+ case "prefixed" :
35+ if err := checkOutputGroupUnset (o ); err != nil {
36+ return nil , err
37+ }
38+ return Prefixed {}, nil
39+ default :
40+ return nil , fmt .Errorf (`task: output style %q not recognized` , o .Name )
41+ }
42+ }
43+
44+ func checkOutputGroupUnset (o * taskfile.Output ) error {
45+ if o .Group .IsSet () {
46+ return fmt .Errorf ("task: output style %q does not support the group begin/end parameter" , o .Name )
47+ }
48+ return nil
49+ }
Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ type Executor struct {
5252 Logger * logger.Logger
5353 Compiler compiler.Compiler
5454 Output output.Output
55- OutputStyle output. Style
55+ OutputStyle taskfile. Output
5656
5757 taskvars * taskfile.Vars
5858
@@ -211,10 +211,9 @@ func (e *Executor) Setup() error {
211211 if ! e .OutputStyle .IsSet () {
212212 e .OutputStyle = e .Taskfile .Output
213213 }
214- if o , err := e .OutputStyle .Build (); err != nil {
214+ e .Output , err = output .BuildFor (& e .OutputStyle )
215+ if err != nil {
215216 return err
216- } else {
217- e .Output = o
218217 }
219218
220219 if e .Taskfile .Method == "" {
Original file line number Diff line number Diff line change 1+ package taskfile
2+
3+ import (
4+ "fmt"
5+ )
6+
7+ // Output of the Task output
8+ type Output struct {
9+ // Name of the Output.
10+ Name string `yaml:"-"`
11+ // Group specific style
12+ Group OutputGroup
13+ }
14+
15+ // IsSet returns true if and only if a custom output style is set.
16+ func (s * Output ) IsSet () bool {
17+ return s .Name != ""
18+ }
19+
20+ // UnmarshalYAML implements yaml.Unmarshaler
21+ // It accepts a scalar node representing the Output.Name or a mapping node representing the OutputGroup.
22+ func (s * Output ) UnmarshalYAML (unmarshal func (interface {}) error ) error {
23+ var name string
24+ if err := unmarshal (& name ); err == nil {
25+ s .Name = name
26+ return nil
27+ }
28+ var tmp struct {
29+ Group * OutputGroup
30+ }
31+ if err := unmarshal (& tmp ); err != nil {
32+ return fmt .Errorf ("task: output style must be a string or mapping with a \" group\" key: %w" , err )
33+ }
34+ if tmp .Group == nil {
35+ return fmt .Errorf ("task: output style must have the \" group\" key when in mapping form" )
36+ }
37+ * s = Output {
38+ Name : "group" ,
39+ Group : * tmp .Group ,
40+ }
41+ return nil
42+ }
43+
44+ // OutputGroup is the style options specific to the Group style.
45+ type OutputGroup struct {
46+ Begin , End string
47+ }
48+
49+ // IsSet returns true if and only if a custom output style is set.
50+ func (g * OutputGroup ) IsSet () bool {
51+ if g == nil {
52+ return false
53+ }
54+ return g .Begin != "" || g .End != ""
55+ }
Original file line number Diff line number Diff line change @@ -3,15 +3,13 @@ package taskfile
33import (
44 "fmt"
55 "strconv"
6-
7- "github.com/go-task/task/v3/internal/output"
86)
97
108// Taskfile represents a Taskfile.yml
119type Taskfile struct {
1210 Version string
1311 Expansions int
14- Output output. Style
12+ Output Output
1513 Method string
1614 Includes * IncludedTaskfiles
1715 Vars * Vars
@@ -27,7 +25,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
2725 var taskfile struct {
2826 Version string
2927 Expansions int
30- Output output. Style
28+ Output Output
3129 Method string
3230 Includes * IncludedTaskfiles
3331 Vars * Vars
You can’t perform that action at this time.
0 commit comments