mirror of
https://github.com/go-task/task.git
synced 2025-11-29 22:48:03 +02:00
feat: add ability to specify which vars are required (#1204)
This commit is contained in:
18
taskfile/requires.go
Normal file
18
taskfile/requires.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package taskfile
|
||||
|
||||
import "github.com/go-task/task/v3/internal/deepcopy"
|
||||
|
||||
// Requires represents a set of required variables necessary for a task to run
|
||||
type Requires struct {
|
||||
Vars []string
|
||||
}
|
||||
|
||||
func (r *Requires) DeepCopy() *Requires {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &Requires{
|
||||
Vars: deepcopy.Slice(r.Vars),
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ type Task struct {
|
||||
Desc string
|
||||
Prompt string
|
||||
Summary string
|
||||
Requires *Requires
|
||||
Aliases []string
|
||||
Sources []string
|
||||
Generates []string
|
||||
@@ -99,6 +100,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
|
||||
IgnoreError bool `yaml:"ignore_error"`
|
||||
Run string
|
||||
Platforms []*Platform
|
||||
Requires *Requires
|
||||
}
|
||||
if err := node.Decode(&task); err != nil {
|
||||
return err
|
||||
@@ -135,6 +137,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
|
||||
t.IgnoreError = task.IgnoreError
|
||||
t.Run = task.Run
|
||||
t.Platforms = task.Platforms
|
||||
t.Requires = task.Requires
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -178,6 +181,7 @@ func (t *Task) DeepCopy() *Task {
|
||||
IncludedTaskfile: t.IncludedTaskfile.DeepCopy(),
|
||||
Platforms: deepcopy.Slice(t.Platforms),
|
||||
Location: t.Location.DeepCopy(),
|
||||
Requires: t.Requires.DeepCopy(),
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user