2018-02-17 14:22:18 -02:00
|
|
|
package taskfile
|
|
|
|
|
|
|
|
// Taskfile represents a Taskfile.yml
|
|
|
|
type Taskfile struct {
|
2018-03-04 15:50:03 -03:00
|
|
|
Version string
|
|
|
|
Expansions int
|
|
|
|
Vars Vars
|
|
|
|
Tasks Tasks
|
2018-02-17 14: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 18:56:15 -03:00
|
|
|
tf.Version = "1"
|
2018-02-17 14:22:18 -02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var taskfile struct {
|
2018-03-04 15:50:03 -03:00
|
|
|
Version string
|
|
|
|
Expansions int
|
|
|
|
Vars Vars
|
|
|
|
Tasks Tasks
|
2018-02-17 14:22:18 -02:00
|
|
|
}
|
|
|
|
if err := unmarshal(&taskfile); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tf.Version = taskfile.Version
|
2018-03-04 15:50:03 -03:00
|
|
|
tf.Expansions = taskfile.Expansions
|
2018-03-04 15:39:14 -03:00
|
|
|
tf.Vars = taskfile.Vars
|
2018-02-17 14:22:18 -02:00
|
|
|
tf.Tasks = taskfile.Tasks
|
2018-03-04 15:50:03 -03:00
|
|
|
if tf.Expansions <= 0 {
|
|
|
|
tf.Expansions = 2
|
|
|
|
}
|
2018-02-17 14:22:18 -02:00
|
|
|
return nil
|
|
|
|
}
|