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:
parent
d6a49da870
commit
8020284b12
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user