2018-02-17 18:22:18 +02:00
|
|
|
package taskfile
|
2017-07-02 20:30:50 +02:00
|
|
|
|
2017-07-06 01:10:45 +02:00
|
|
|
// Cmd is a task command
|
2017-07-02 20:30:50 +02:00
|
|
|
type Cmd struct {
|
2018-07-10 10:44:58 +02:00
|
|
|
Cmd string
|
|
|
|
Silent bool
|
|
|
|
Task string
|
2020-03-29 21:54:59 +02:00
|
|
|
Vars *Vars
|
2018-07-10 10:44:58 +02:00
|
|
|
IgnoreError bool
|
2021-12-15 07:03:37 +02:00
|
|
|
Defer bool
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
|
|
|
|
2017-07-06 01:10:45 +02:00
|
|
|
// Dep is a task dependency
|
2017-07-02 20:30:50 +02:00
|
|
|
type Dep struct {
|
2018-08-01 10:44:53 +02:00
|
|
|
Task string
|
2020-03-29 21:54:59 +02:00
|
|
|
Vars *Vars
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
|
|
|
|
2017-07-06 01:10:45 +02:00
|
|
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
2017-07-02 20:30:50 +02:00
|
|
|
func (c *Cmd) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
|
|
var cmd string
|
|
|
|
if err := unmarshal(&cmd); err == nil {
|
2022-01-02 20:15:54 +02:00
|
|
|
c.Cmd = cmd
|
2017-07-02 20:30:50 +02:00
|
|
|
return nil
|
|
|
|
}
|
2017-07-20 01:20:24 +02:00
|
|
|
var cmdStruct struct {
|
2018-07-10 10:44:58 +02:00
|
|
|
Cmd string
|
|
|
|
Silent bool
|
2018-08-01 10:44:53 +02:00
|
|
|
IgnoreError bool `yaml:"ignore_error"`
|
2017-07-20 01:20:24 +02:00
|
|
|
}
|
|
|
|
if err := unmarshal(&cmdStruct); err == nil && cmdStruct.Cmd != "" {
|
|
|
|
c.Cmd = cmdStruct.Cmd
|
|
|
|
c.Silent = cmdStruct.Silent
|
2018-07-10 10:44:58 +02:00
|
|
|
c.IgnoreError = cmdStruct.IgnoreError
|
2017-07-20 01:20:24 +02:00
|
|
|
return nil
|
|
|
|
}
|
2021-12-15 07:03:37 +02:00
|
|
|
var deferredCmd struct {
|
|
|
|
Defer string
|
|
|
|
}
|
|
|
|
if err := unmarshal(&deferredCmd); err == nil && deferredCmd.Defer != "" {
|
|
|
|
c.Defer = true
|
2022-01-02 23:38:06 +02:00
|
|
|
c.Cmd = deferredCmd.Defer
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var deferredCall struct {
|
2022-01-04 21:56:13 +02:00
|
|
|
Defer Call
|
2022-01-02 23:38:06 +02:00
|
|
|
}
|
|
|
|
if err := unmarshal(&deferredCall); err == nil && deferredCall.Defer.Task != "" {
|
|
|
|
c.Defer = true
|
|
|
|
c.Task = deferredCall.Defer.Task
|
|
|
|
c.Vars = deferredCall.Defer.Vars
|
2021-12-15 07:03:37 +02:00
|
|
|
return nil
|
|
|
|
}
|
2017-07-02 20:30:50 +02:00
|
|
|
var taskCall struct {
|
2018-08-01 10:44:53 +02:00
|
|
|
Task string
|
2020-03-29 21:54:59 +02:00
|
|
|
Vars *Vars
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
2021-04-17 22:12:39 +02:00
|
|
|
if err := unmarshal(&taskCall); err != nil {
|
|
|
|
return err
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
2021-04-17 22:12:39 +02:00
|
|
|
c.Task = taskCall.Task
|
|
|
|
c.Vars = taskCall.Vars
|
|
|
|
return nil
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
|
|
|
|
2017-07-06 01:10:45 +02:00
|
|
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
2017-07-02 20:30:50 +02:00
|
|
|
func (d *Dep) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
|
|
var task string
|
|
|
|
if err := unmarshal(&task); err == nil {
|
|
|
|
d.Task = task
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var taskCall struct {
|
2018-08-01 10:44:53 +02:00
|
|
|
Task string
|
2020-03-29 21:54:59 +02:00
|
|
|
Vars *Vars
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
2021-04-17 22:12:39 +02:00
|
|
|
if err := unmarshal(&taskCall); err != nil {
|
|
|
|
return err
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|
2021-04-17 22:12:39 +02:00
|
|
|
d.Task = taskCall.Task
|
|
|
|
d.Vars = taskCall.Vars
|
|
|
|
return nil
|
2017-07-02 20:30:50 +02:00
|
|
|
}
|