mirror of
https://github.com/go-task/task.git
synced 2026-07-08 22:46:07 +00:00
feat: remove v2 support (#1447)
* feat: remove v2 support * docs: update v2 schema docs
This commit is contained in:
30
args/args.go
30
args/args.go
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/go-task/task/v3/taskfile"
|
||||
)
|
||||
|
||||
// ParseV3 parses command line argument: tasks and global variables
|
||||
func ParseV3(args ...string) ([]taskfile.Call, *taskfile.Vars) {
|
||||
// Parse parses command line argument: tasks and global variables
|
||||
func Parse(args ...string) ([]taskfile.Call, *taskfile.Vars) {
|
||||
calls := []taskfile.Call{}
|
||||
globals := &taskfile.Vars{}
|
||||
|
||||
@@ -24,32 +24,6 @@ func ParseV3(args ...string) ([]taskfile.Call, *taskfile.Vars) {
|
||||
return calls, globals
|
||||
}
|
||||
|
||||
// ParseV2 parses command line argument: tasks and vars of each task
|
||||
func ParseV2(args ...string) ([]taskfile.Call, *taskfile.Vars) {
|
||||
calls := []taskfile.Call{}
|
||||
globals := &taskfile.Vars{}
|
||||
|
||||
for _, arg := range args {
|
||||
if !strings.Contains(arg, "=") {
|
||||
calls = append(calls, taskfile.Call{Task: arg, Direct: true})
|
||||
continue
|
||||
}
|
||||
|
||||
if len(calls) < 1 {
|
||||
name, value := splitVar(arg)
|
||||
globals.Set(name, taskfile.Var{Value: value})
|
||||
} else {
|
||||
if calls[len(calls)-1].Vars == nil {
|
||||
calls[len(calls)-1].Vars = &taskfile.Vars{}
|
||||
}
|
||||
name, value := splitVar(arg)
|
||||
calls[len(calls)-1].Vars.Set(name, taskfile.Var{Value: value})
|
||||
}
|
||||
}
|
||||
|
||||
return calls, globals
|
||||
}
|
||||
|
||||
func splitVar(s string) (string, string) {
|
||||
pair := strings.SplitN(s, "=", 2)
|
||||
return pair[0], pair[1]
|
||||
|
||||
Reference in New Issue
Block a user