@@ -5,6 +5,10 @@ REM we want jruby-complete to take care of all things ruby
5
5
SET GEM_HOME =
6
6
SET GEM_PATH =
7
7
8
+ # This code supports both:
9
+ # ./go " namespace:task[--arg1,--arg2]" --rake-flag
10
+ # ./go namespace:task --arg1 --arg2 -- --rake-flag
11
+
8
12
REM The first argument is always the Rake task name
9
13
SET task = %1
10
14
@@ -14,33 +18,62 @@ IF "%task%"=="" (
14
18
exit /b 1
15
19
)
16
20
17
- REM Shift the task off and get the remaining arguments
21
+ REM Shift the task off
18
22
SHIFT
19
23
20
24
REM Leave task alone if already passing in arguments the normal way
21
25
ECHO %task% | FINDSTR /C:" [" > NUL
22
26
IF %ERRORLEVEL% EQU 0 (
23
- GOTO execute
27
+ GOTO execute_with_args
24
28
)
25
29
26
- REM Process remaining arguments
27
- SET args =
30
+ REM Initialize variables for task arguments and rake flags
31
+ SET task_args =
32
+ SET rake_flags =
33
+ SET separator_found = false
34
+
35
+ REM Process arguments until we find --
28
36
:process_args
29
37
IF " %1 " == " " GOTO done_args
30
- IF " !args! " == " " (
31
- SET args = %1
38
+
39
+ IF " %1 " == " --" (
40
+ SET separator_found = true
41
+ SHIFT
42
+ GOTO collect_rake_flags
43
+ )
44
+
45
+ REM Add to task arguments
46
+ IF " !task_args! " == " " (
47
+ SET task_args = %1
32
48
) ELSE (
33
- SET args = !args ! ,%1
49
+ SET task_args = !task_args ! ,%1
34
50
)
35
51
SHIFT
36
52
GOTO process_args
37
53
54
+ REM Collect remaining arguments as rake flags
55
+ :collect_rake_flags
56
+ IF " %1 " == " " GOTO done_args
57
+ IF " !rake_flags! " == " " (
58
+ SET rake_flags = %1
59
+ ) ELSE (
60
+ SET rake_flags = !rake_flags! %1
61
+ )
62
+ SHIFT
63
+ GOTO collect_rake_flags
64
+
38
65
:done_args
39
- REM If there are any arguments , format them as task[arg1,arg2,...]
40
- IF NOT " !args ! " == " " (
41
- SET task = %task% [!args ! ]
66
+ REM If we have task args , format them as task[arg1,arg2,...]
67
+ IF NOT " !task_args ! " == " " (
68
+ SET task = %task% [!task_args ! ]
42
69
ECHO Executing rake task: %task%
43
70
)
44
71
45
72
:execute
46
- java %JAVA_OPTS% -jar third_party\jruby\jruby-complete.jar -X-C -S rake %task%
73
+ REM Execute rake with the task and flags
74
+ java %JAVA_OPTS% -jar third_party\jruby\jruby-complete.jar -X-C -S rake %task% %rake_flags%
75
+ GOTO :EOF
76
+
77
+ :execute_with_args
78
+ REM Task already has arguments in brackets, pass remaining args directly to rake
79
+ java %JAVA_OPTS% -jar third_party\jruby\jruby-complete.jar -X-C -S rake %task% %*
0 commit comments