1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

feat: support negative globs (#1324)

Co-authored-by: Andrey Nering <andrey@nering.com.br>
This commit is contained in:
Pete Davison
2023-11-29 19:38:12 -06:00
committed by GitHub
parent a7958c0e3b
commit ec35d43677
14 changed files with 173 additions and 50 deletions

32
taskfile/glob.go Normal file
View File

@@ -0,0 +1,32 @@
package taskfile
import (
"fmt"
"gopkg.in/yaml.v3"
)
type Glob struct {
Glob string
Negate bool
}
func (g *Glob) UnmarshalYAML(node *yaml.Node) error {
switch node.Kind {
case yaml.ScalarNode:
g.Glob = node.Value
return nil
case yaml.MappingNode:
var glob struct {
Exclude string
}
if err := node.Decode(&glob); err != nil {
return err
}
g.Glob = glob.Exclude
g.Negate = true
return nil
default:
return fmt.Errorf("yaml: line %d: cannot unmarshal %s into task", node.Line, node.ShortTag())
}
}

View File

@@ -19,8 +19,8 @@ type Task struct {
Summary string
Requires *Requires
Aliases []string
Sources []string
Generates []string
Sources []*Glob
Generates []*Glob
Status []string
Preconditions []*Precondition
Dir string
@@ -83,8 +83,8 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
Prompt string
Summary string
Aliases []string
Sources []string
Generates []string
Sources []*Glob
Generates []*Glob
Status []string
Preconditions []*Precondition
Dir string