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
|
|
|
|
Tasks Tasks
|
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
|
|
|
|
Tasks Tasks
|
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
|
2018-02-17 18:22:18 +02:00
|
|
|
tf.Tasks = taskfile.Tasks
|
2018-03-04 20:50:03 +02:00
|
|
|
if tf.Expansions <= 0 {
|
|
|
|
tf.Expansions = 2
|
|
|
|
}
|
2018-02-17 18:22:18 +02:00
|
|
|
return nil
|
|
|
|
}
|