1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

Add support for delegating CLI arguments with "--" and a special CLI_ARGS variable

Closes #327
This commit is contained in:
Andrey Nering
2021-03-20 11:56:19 -03:00
parent 8994c50d34
commit e6c4706b73
7 changed files with 68 additions and 16 deletions

View File

@@ -75,7 +75,7 @@ func (vs *Vars) Range(yield func(key string, value Var) error) error {
// ToCacheMap converts Vars to a map containing only the static
// variables
func (vs *Vars) ToCacheMap() (m map[string]interface{}) {
m = make(map[string]interface{}, len(vs.Keys))
m = make(map[string]interface{}, vs.Len())
vs.Range(func(k string, v Var) error {
if v.Sh != "" {
// Dynamic variable is not yet resolved; trigger
@@ -93,6 +93,14 @@ func (vs *Vars) ToCacheMap() (m map[string]interface{}) {
return
}
// Len returns the size of the map
func (vs *Vars) Len() int {
if vs == nil {
return 0
}
return len(vs.Keys)
}
// Var represents either a static or dynamic variable.
type Var struct {
Static string