// NewTask creates a new Task. func NewTask(name string, argm minimist.ArgMap) *Task { runOnce := false if strings.HasSuffix(name, "?") { runOnce = true name = str.ChompRight(name, "?") } return &Task{Name: name, RunOnce: runOnce, dependencies: Series{}, argm: argm} }
// Task adds a task to the project. func (project *Project) Task(name string, args ...interface{}) *Task { runOnce := false if strings.HasSuffix(name, "?") { runOnce = true name = str.ChompRight(name, "?") } task := &Task{Name: name, RunOnce: runOnce} for _, t := range args { switch t := t.(type) { default: util.Panic("project", "unexpected type %T\n", t) // %T prints whatever type t has case Watch: task.Watch(t...) printDeprecatedWatchWarning(name, t) case W: task.Watch(t...) printDeprecatedWatchWarning(name, t) case Dependencies: task.Dependencies = t case D: task.Dependencies = t case Debounce: task.Debounce(int64(t)) printDeprecatedDebounceWarning(name, int64(t)) case func(): task.Handler = VoidHandlerFunc(t) case func() error: task.Handler = HandlerFunc(t) case func(*Context): task.Handler = VoidContextHandlerFunc(t) case func(*Context) error: task.Handler = ContextHandlerFunc(t) case string: task.Description(t) printDeprecatedDescriptionWarning(name, t) } } project.Tasks[name] = task return task }