@@ -12,6 +12,7 @@ import (
12
12
"syscall"
13
13
14
14
"github.com/spf13/pflag"
15
+ "mvdan.cc/sh/v3/syntax"
15
16
16
17
"github.com/go-task/task/v3"
17
18
"github.com/go-task/task/v3/args"
@@ -76,7 +77,7 @@ func main() {
76
77
77
78
pflag .BoolVar (& versionFlag , "version" , false , "show Task version" )
78
79
pflag .BoolVarP (& helpFlag , "help" , "h" , false , "shows Task usage" )
79
- pflag .BoolVarP (& init , "init" , "i" , false , "creates a new Taskfile.yml in the current folder" )
80
+ pflag .BoolVarP (& init , "init" , "i" , false , "creates a new Taskfile.yaml in the current folder" )
80
81
pflag .BoolVarP (& list , "list" , "l" , false , "lists tasks with description of current Taskfile" )
81
82
pflag .BoolVar (& status , "status" , false , "exits with non-zero exit code if any of the given tasks is not up-to-date" )
82
83
pflag .BoolVarP (& force , "force" , "f" , false , "forces execution even when the task is up-to-date" )
@@ -121,8 +122,6 @@ func main() {
121
122
if entrypoint != "" {
122
123
dir = filepath .Dir (entrypoint )
123
124
entrypoint = filepath .Base (entrypoint )
124
- } else {
125
- entrypoint = "Taskfile.yml"
126
125
}
127
126
128
127
e := task.Executor {
@@ -159,18 +158,22 @@ func main() {
159
158
}
160
159
161
160
var (
162
- calls []taskfile.Call
163
- globals * taskfile.Vars
164
- tasksAndVars , cliArgs = getArgs ()
161
+ calls []taskfile.Call
162
+ globals * taskfile.Vars
165
163
)
166
164
165
+ tasksAndVars , cliArgs , err := getArgs ()
166
+ if err != nil {
167
+ log .Fatal (err )
168
+ }
169
+
167
170
if v >= 3.0 {
168
171
calls , globals = args .ParseV3 (tasksAndVars ... )
169
172
} else {
170
173
calls , globals = args .ParseV2 (tasksAndVars ... )
171
174
}
172
175
173
- globals .Set ("CLI_ARGS" , taskfile.Var {Static : strings . Join ( cliArgs , " " ) })
176
+ globals .Set ("CLI_ARGS" , taskfile.Var {Static : cliArgs })
174
177
e .Taskfile .Vars .Merge (globals )
175
178
176
179
ctx := context .Background ()
@@ -191,20 +194,25 @@ func main() {
191
194
}
192
195
}
193
196
194
- func getArgs () (tasksAndVars , cliArgs []string ) {
197
+ func getArgs () ([]string , string , error ) {
195
198
var (
196
199
args = pflag .Args ()
197
200
doubleDashPos = pflag .CommandLine .ArgsLenAtDash ()
198
201
)
199
202
200
- if doubleDashPos != - 1 {
201
- tasksAndVars = args [:doubleDashPos ]
202
- cliArgs = args [doubleDashPos :]
203
- } else {
204
- tasksAndVars = args
203
+ if doubleDashPos == - 1 {
204
+ return args , "" , nil
205
205
}
206
206
207
- return
207
+ var quotedCliArgs []string
208
+ for _ , arg := range args [doubleDashPos :] {
209
+ quotedCliArg , err := syntax .Quote (arg , syntax .LangBash )
210
+ if err != nil {
211
+ return nil , "" , err
212
+ }
213
+ quotedCliArgs = append (quotedCliArgs , quotedCliArg )
214
+ }
215
+ return args [:doubleDashPos ], strings .Join (quotedCliArgs , " " ), nil
208
216
}
209
217
210
218
func getSignalContext () context.Context {
0 commit comments