1
0
mirror of https://github.com/go-task/task.git synced 2025-02-09 13:47:06 +02:00

Add global method: option to set default method

This commit is contained in:
Andrey Nering 2019-09-08 22:26:24 -03:00
parent d6a49da870
commit 8020284b12
2 changed files with 9 additions and 2 deletions

View File

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

View File

@ -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)
}
}