2018-02-17 18:22:18 +02:00
|
|
|
package taskfile
|
|
|
|
|
|
|
|
// Taskfile represents a Taskfile.yml
|
|
|
|
type Taskfile struct {
|
2018-03-04 20:50:03 +02:00
|
|
|
Version string
|
|
|
|
Expansions int
|
2018-04-15 16:11:07 +02:00
|
|
|
Output string
|
2018-09-10 03:29:29 +02:00
|
|
|
Includes map[string]string
|
2018-03-04 20:50:03 +02:00
|
|
|
Vars Vars
|
2019-01-02 16:05:40 +02:00
|
|
|
Env Vars
|
2018-03-04 20:50:03 +02:00
|
|
|
Tasks Tasks
|
2019-12-08 02:44:09 +02:00
|
|
|
Silent bool
|
2018-02-17 18:22:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
|
|
|
func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
|
|
if err := unmarshal(&tf.Tasks); err == nil {
|
2018-03-03 23:56:15 +02:00
|
|
|
tf.Version = "1"
|
2018-02-17 18:22:18 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var taskfile struct {
|
2018-03-04 20:50:03 +02:00
|
|
|
Version string
|
|
|
|
Expansions int
|
2018-04-15 16:11:07 +02:00
|
|
|
Output string
|
2018-09-10 03:29:29 +02:00
|
|
|
Includes map[string]string
|
2018-03-04 20:50:03 +02:00
|
|
|
Vars Vars
|
2019-01-02 16:05:40 +02:00
|
|
|
Env Vars
|
2018-03-04 20:50:03 +02:00
|
|
|
Tasks Tasks
|
2019-12-08 02:44:09 +02:00
|
|
|
Silent bool
|
2018-02-17 18:22:18 +02:00
|
|
|
}
|
|
|
|
if err := unmarshal(&taskfile); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tf.Version = taskfile.Version
|
2018-03-04 20:50:03 +02:00
|
|
|
tf.Expansions = taskfile.Expansions
|
2018-04-15 16:11:07 +02:00
|
|
|
tf.Output = taskfile.Output
|
2018-09-10 03:29:29 +02:00
|
|
|
tf.Includes = taskfile.Includes
|
2018-03-04 20:39:14 +02:00
|
|
|
tf.Vars = taskfile.Vars
|
2019-01-02 16:05:40 +02:00
|
|
|
tf.Env = taskfile.Env
|
2018-02-17 18:22:18 +02:00
|
|
|
tf.Tasks = taskfile.Tasks
|
2019-12-08 02:44:09 +02:00
|
|
|
tf.Silent = taskfile.Silent
|
2018-03-04 20:50:03 +02:00
|
|
|
if tf.Expansions <= 0 {
|
|
|
|
tf.Expansions = 2
|
|
|
|
}
|
2019-08-11 00:38:57 +02:00
|
|
|
if tf.Vars == nil {
|
|
|
|
tf.Vars = make(Vars)
|
|
|
|
}
|
2018-02-17 18:22:18 +02:00
|
|
|
return nil
|
|
|
|
}
|