@@ -5,6 +5,10 @@ REM we want jruby-complete to take care of all things ruby
55SET GEM_HOME =
66SET GEM_PATH =
77
8+ # This code supports both:
9+ # ./go " namespace:task[--arg1,--arg2]" --rake-flag
10+ # ./go namespace:task --arg1 --arg2 -- --rake-flag
11+
812REM The first argument is always the Rake task name
913SET task = %1
1014
@@ -14,33 +18,62 @@ IF "%task%"=="" (
1418 exit /b 1
1519)
1620
17- REM Shift the task off and get the remaining arguments
21+ REM Shift the task off
1822SHIFT
1923
2024REM Leave task alone if already passing in arguments the normal way
2125ECHO %task% | FINDSTR /C:" [" > NUL
2226IF %ERRORLEVEL% EQU 0 (
23- GOTO execute
27+ GOTO execute_with_args
2428)
2529
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 --
2836:process_args
2937IF " %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
3248) ELSE (
33- SET args = !args ! ,%1
49+ SET task_args = !task_args ! ,%1
3450)
3551SHIFT
3652GOTO process_args
3753
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+
3865: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 ! ]
4269 ECHO Executing rake task: %task%
4370)
4471
4572: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