mirror of
https://github.com/go-task/task.git
synced 2026-06-11 09:51:50 +00:00
feat: add support for single cmd task syntax (#1131)
This commit is contained in:
@@ -74,6 +74,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
|
||||
case yaml.MappingNode:
|
||||
var task struct {
|
||||
Cmds []*Cmd
|
||||
Cmd *Cmd
|
||||
Deps []*Dep
|
||||
Label string
|
||||
Desc string
|
||||
@@ -102,7 +103,14 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
|
||||
if err := node.Decode(&task); err != nil {
|
||||
return err
|
||||
}
|
||||
t.Cmds = task.Cmds
|
||||
if task.Cmd != nil {
|
||||
if task.Cmds != nil {
|
||||
return fmt.Errorf("yaml: line %d: task cannot have both cmd and cmds", node.Line)
|
||||
}
|
||||
t.Cmds = []*Cmd{task.Cmd}
|
||||
} else {
|
||||
t.Cmds = task.Cmds
|
||||
}
|
||||
t.Deps = task.Deps
|
||||
t.Label = task.Label
|
||||
t.Desc = task.Desc
|
||||
|
||||
Reference in New Issue
Block a user