Skip to content

Commit

Permalink
Merge pull request #173 from kjdev/master
Browse files Browse the repository at this point in the history
Add execute output style options
  • Loading branch information
andreynering authored Feb 7, 2019
2 parents 2cb070f + a026d72 commit 14f41ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {
silent bool
dry bool
dir string
output string
)

pflag.BoolVar(&versionFlag, "version", false, "show Task version")
Expand All @@ -69,6 +70,7 @@ func main() {
pflag.BoolVarP(&silent, "silent", "s", false, "disables echoing")
pflag.BoolVar(&dry, "dry", false, "compiles and prints tasks in the order that they would be run, without executing them")
pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution")
pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]")
pflag.Parse()

if versionFlag {
Expand Down Expand Up @@ -105,6 +107,8 @@ func main() {
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,

OutputStyle: output,
}
if err := e.Setup(); err != nil {
log.Fatal(err)
Expand Down
4 changes: 4 additions & 0 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Executor struct {
Logger *logger.Logger
Compiler compiler.Compiler
Output output.Output
OutputStyle string

taskvars taskfile.Vars

Expand Down Expand Up @@ -134,6 +135,9 @@ func (e *Executor) Setup() error {
if !version.IsV22(v) && len(e.Taskfile.Includes) > 0 {
return fmt.Errorf(`task: Including Taskfiles is only available starting on Taskfile version v2.2`)
}
if e.OutputStyle != "" {
e.Taskfile.Output = e.OutputStyle
}
switch e.Taskfile.Output {
case "", "interleaved":
e.Output = output.Interleaved{}
Expand Down

0 comments on commit 14f41ae

Please sign in to comment.