Skip to content

Commit b7cf0b9

Browse files
committed
apply review
1 parent a1a943b commit b7cf0b9

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

taskfile/ast/prompt.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
package ast
22

3+
import (
4+
"gopkg.in/yaml.v3"
5+
6+
"github.com/go-task/task/v3/errors"
7+
)
8+
39
type Prompt []string
410

5-
func (p *Prompt) UnmarshalYAML(unmarshal func(any) error) error {
6-
var m []string
7-
err := unmarshal(&m)
8-
if err == nil {
9-
*p = m
11+
func (p *Prompt) UnmarshalYAML(node *yaml.Node) error {
12+
switch node.Kind {
13+
case yaml.ScalarNode:
14+
var str string
15+
if err := node.Decode(&str); err != nil {
16+
return errors.NewTaskfileDecodeError(err, node)
17+
}
18+
*p = []string{str}
19+
return nil
20+
case yaml.SequenceNode:
21+
var list []string
22+
if err := node.Decode(&list); err != nil {
23+
return errors.NewTaskfileDecodeError(err, node)
24+
}
25+
*p = list
1026
return nil
1127
}
12-
13-
var s string
14-
err = unmarshal(&s)
15-
if err != nil {
16-
return err
17-
}
18-
19-
*p = []string{s}
20-
return nil
28+
return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("prompt")
2129
}

website/static/schema.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@
6060
},
6161
"prompt": {
6262
"description": "One or more prompts that will be presented before a task is run. Declining will cancel running the current and any subsequent tasks.",
63-
"type": "array",
64-
"items": {
65-
"type": "string"
66-
}
63+
"oneOf": [
64+
{
65+
"type": "string"
66+
},
67+
{
68+
"type": "array",
69+
"items": {
70+
"type": "string"
71+
}
72+
}
73+
]
6774
},
6875
"summary": {
6976
"description": "A longer description of the task. This is displayed when calling `task --summary [task]`.",

0 commit comments

Comments
 (0)