MCPcopy Index your code
hub / github.com/go-task/task / UnmarshalYAML

Method UnmarshalYAML

taskfile/ast/task.go:112–212  ·  view source on GitHub ↗
(node *yaml.Node)

Source from the content-addressed store, hash-verified

110}
111
112func (t *Task) UnmarshalYAML(node *yaml.Node) error {
113 switch node.Kind {
114
115 // Shortcut syntax for a task with a single command
116 case yaml.ScalarNode:
117 var cmd Cmd
118 if err := node.Decode(&cmd); err != nil {
119 return errors.NewTaskfileDecodeError(err, node)
120 }
121 t.Cmds = append(t.Cmds, &cmd)
122 return nil
123
124 // Shortcut syntax for a simple task with a list of commands
125 case yaml.SequenceNode:
126 var cmds []*Cmd
127 if err := node.Decode(&cmds); err != nil {
128 return errors.NewTaskfileDecodeError(err, node)
129 }
130 t.Cmds = cmds
131 return nil
132
133 // Full task object
134 case yaml.MappingNode:
135 var task struct {
136 Cmds []*Cmd
137 Cmd *Cmd
138 Deps []*Dep
139 Label string
140 Desc string
141 Prompt Prompt
142 Summary string
143 Aliases []string
144 Sources []*Glob
145 Generates []*Glob
146 Status []string
147 Preconditions []*Precondition
148 Dir string
149 Set []string
150 Shopt []string
151 Vars *Vars
152 Env *Vars
153 Dotenv []string
154 Silent *bool `yaml:"silent,omitempty"`
155 Interactive bool
156 Internal bool
157 Method string
158 Prefix string
159 IgnoreError bool `yaml:"ignore_error"`
160 UseGitignore *bool `yaml:"use_gitignore,omitempty"`
161 Run string
162 Platforms []*Platform
163 If string
164 Requires *Requires
165 Watch bool
166 Failfast bool
167 }
168 if err := node.Decode(&task); err != nil {
169 return errors.NewTaskfileDecodeError(err, node)

Callers

nothing calls this directly

Calls 4

NewTaskfileDecodeErrorFunction · 0.92
ScalarFunction · 0.92
WithMessageMethod · 0.80
WithTypeMessageMethod · 0.80

Tested by

no test coverage detected