From 8020284b12e8d5d274a05ef23b5d497a886e3e04 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 8 Sep 2019 22:26:24 -0300 Subject: [PATCH] Add global method: option to set default method --- internal/taskfile/taskfile.go | 3 +++ status.go | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/taskfile/taskfile.go b/internal/taskfile/taskfile.go index c7931788..da966691 100644 --- a/internal/taskfile/taskfile.go +++ b/internal/taskfile/taskfile.go @@ -5,6 +5,7 @@ type Taskfile struct { Version string Expansions int Output string + Method string Includes map[string]string Vars Vars Env Vars @@ -17,6 +18,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error { Version string Expansions int Output string + Method string Includes map[string]string Vars Vars Env Vars @@ -28,6 +30,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error { tf.Version = taskfile.Version tf.Expansions = taskfile.Expansions tf.Output = taskfile.Output + tf.Method = taskfile.Method tf.Includes = taskfile.Includes tf.Vars = taskfile.Vars tf.Env = taskfile.Env diff --git a/status.go b/status.go index da8a8472..554bb569 100644 --- a/status.go +++ b/status.go @@ -50,7 +50,11 @@ func (e *Executor) statusOnError(t *taskfile.Task) error { } func (e *Executor) getStatusChecker(t *taskfile.Task) (status.Checker, error) { - switch t.Method { + method := t.Method + if method == "" { + method = e.Taskfile.Method + } + switch method { case "", "timestamp": return &status.Timestamp{ Dir: t.Dir, @@ -68,7 +72,7 @@ func (e *Executor) getStatusChecker(t *taskfile.Task) (status.Checker, error) { case "none": return status.None{}, nil default: - return nil, fmt.Errorf(`task: invalid method "%s"`, t.Method) + return nil, fmt.Errorf(`task: invalid method "%s"`, method) } }