2025-02-22 15:44:22 +00:00
|
|
|
package ast
|
|
|
|
|
|
|
|
|
|
import (
|
2025-11-11 16:49:37 -03:00
|
|
|
"go.yaml.in/yaml/v4"
|
2025-02-22 15:44:22 +00:00
|
|
|
|
|
|
|
|
"github.com/go-task/task/v3/errors"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Defer struct {
|
|
|
|
|
Cmd string
|
|
|
|
|
Task string
|
|
|
|
|
Vars *Vars
|
|
|
|
|
Silent bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *Defer) UnmarshalYAML(node *yaml.Node) error {
|
|
|
|
|
switch node.Kind {
|
|
|
|
|
|
|
|
|
|
case yaml.ScalarNode:
|
|
|
|
|
var cmd string
|
|
|
|
|
if err := node.Decode(&cmd); err != nil {
|
|
|
|
|
return errors.NewTaskfileDecodeError(err, node)
|
|
|
|
|
}
|
|
|
|
|
d.Cmd = cmd
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
|
|
case yaml.MappingNode:
|
|
|
|
|
var deferStruct struct {
|
|
|
|
|
Defer string
|
|
|
|
|
Task string
|
|
|
|
|
Vars *Vars
|
|
|
|
|
Silent bool
|
|
|
|
|
}
|
|
|
|
|
if err := node.Decode(&deferStruct); err != nil {
|
|
|
|
|
return errors.NewTaskfileDecodeError(err, node)
|
|
|
|
|
}
|
|
|
|
|
d.Cmd = deferStruct.Defer
|
|
|
|
|
d.Task = deferStruct.Task
|
|
|
|
|
d.Vars = deferStruct.Vars
|
|
|
|
|
d.Silent = deferStruct.Silent
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("defer")
|
|
|
|
|
}
|