1
0
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:
Ben Coleman
2023-06-30 02:13:41 +01:00
committed by GitHub
parent f346015d8c
commit 307f39cee3
10 changed files with 165 additions and 3 deletions

18
taskfile/requires.go Normal file
View 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),
}
}

View File

@@ -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
}