1
0
mirror of https://github.com/go-task/task.git synced 2025-01-12 04:34:11 +02:00

Added structure for storage information about included tasks

This commit is contained in:
Evgeny Abramovich 2020-01-29 10:02:22 +03:00
parent 15338ecb18
commit eaba1b9cc8

View File

@ -0,0 +1,38 @@
package taskfile
import "errors"
var (
// ErrCantUnmarshalIncludedTaskFile is returned for invalid var YAML.
ErrCantUnmarshalIncludedTaskFile = errors.New("task: can't unmarshal included value")
)
// IncludedTaskFile represents information about included tasksfile
type IncludedTaskFile struct {
Taskfile string
Dir string
}
// IncludedTaskFiles represents information about included tasksfiles
type IncludedTaskFiles = map[string]IncludedTaskFile
// UnmarshalYAML implements yaml.Unmarshaler interface
func (it *IncludedTaskFile) UnmarshalYAML(unmarshal func(interface{}) error) error {
var str string
if err := unmarshal(&str); err == nil {
it.Taskfile = str
return nil
}
var includedTaskfile struct {
Taskfile string
Dir string
}
if err := unmarshal(&includedTaskfile); err == nil {
it.Dir = includedTaskfile.Dir
it.Taskfile = includedTaskfile.Taskfile
return nil
}
return ErrCantUnmarshalIncludedTaskFile
}