-
-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow providing single or multi prompts (#1866)
* Add new type to handle single or multi prompts * update docs * apply review
- Loading branch information
Showing
7 changed files
with
78 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ast | ||
|
||
import ( | ||
"gopkg.in/yaml.v3" | ||
|
||
"github.com/go-task/task/v3/errors" | ||
) | ||
|
||
type Prompt []string | ||
|
||
func (p *Prompt) UnmarshalYAML(node *yaml.Node) error { | ||
switch node.Kind { | ||
case yaml.ScalarNode: | ||
var str string | ||
if err := node.Decode(&str); err != nil { | ||
return errors.NewTaskfileDecodeError(err, node) | ||
} | ||
*p = []string{str} | ||
return nil | ||
case yaml.SequenceNode: | ||
var list []string | ||
if err := node.Decode(&list); err != nil { | ||
return errors.NewTaskfileDecodeError(err, node) | ||
} | ||
*p = list | ||
return nil | ||
} | ||
return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("prompt") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters