@@ -74,7 +74,7 @@ func main() {
7474 os .Exit (1 )
7575 }
7676
77- opts .tasks , opts .cliArgs = parseArgs (flag .Args ())
77+ opts .tasks , opts .cliArgs = parseArgs (flag .Args (), flag . CommandLine . ArgsLenAtDash () )
7878
7979 // cfg is the parsed task file
8080 cfg , err := task .NewTaskConfig (opts .taskFile , opts .cliArgs , opts .listTasks )
@@ -114,31 +114,11 @@ func main() {
114114 exec .RunTasks (exec .Config , & opts .tasks )
115115}
116116
117- // splits args like [task1, task2 --, arg1, arg2] into
118- // - tasks = []string{"task1", "task2"}
119- // - cliArgs = "arg1 arg2"
120- func parseArgs (args []string ) (tasks []string , cliArgs string ) {
121- cliArgsIndex := func () int {
122- for index , arg := range args {
123- if arg == "--" {
124- return index
125- }
126- }
127- return - 1
128- }()
129-
130- hasCliArgs := func () bool {
131- if cliArgsIndex >= 0 {
132- return true
133- }
134- return false
135- }()
136-
137- if hasCliArgs {
138- tasks = args [:cliArgsIndex ]
139- cliArgs = strings .Join (args [cliArgsIndex + 1 :], " " )
140- return
117+ func parseArgs (args []string , dashIndex int ) (tasks []string , cliArgs string ) {
118+ if dashIndex >= 0 {
119+ tasks = args [:dashIndex ]
120+ cliArgs = strings .Join (args [dashIndex :], " " )
121+ return tasks , cliArgs
141122 }
142-
143123 return args , ""
144124}
0 commit comments