mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
22ce67c5e5
* feat: remote taskfiles over http * feat: allow insecure connections when --insecure flag is provided * feat: better error handling for fetch errors * fix: ensure cache directory always exists * fix: setup logger before everything else * feat: put remote taskfiles behind an experiment * feat: --download and --offline flags for remote taskfiles * feat: node.Read accepts a context * feat: experiment docs * chore: changelog * chore: remove unused optional param from Node interface * chore: tidy up and generalise NewNode function * fix: use sha256 in remote checksum * feat: --download by itself will not run a task * feat: custom error if remote taskfiles experiment is not enabled * refactor: BaseNode functional options and simplified FileNode * fix: use hex encoding for checksum instead of b64
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package args
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/go-task/task/v3/taskfile"
|
|
)
|
|
|
|
// ParseV3 parses command line argument: tasks and global variables
|
|
func ParseV3(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
|
|
}
|
|
|
|
name, value := splitVar(arg)
|
|
globals.Set(name, taskfile.Var{Static: value})
|
|
}
|
|
|
|
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{Static: 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{Static: value})
|
|
}
|
|
}
|
|
|
|
return calls, globals
|
|
}
|
|
|
|
func splitVar(s string) (string, string) {
|
|
pair := strings.SplitN(s, "=", 2)
|
|
return pair[0], pair[1]
|
|
}
|