rakefile task does not accept second parameters

92 Views Asked by At

I have piece of code from my rakefile. Few tasks have to have multiple parameters.

desc 'confidential'
  task :task1, [:targetPrj, :arg1] do |t,args|
  args.with_defaults(:arg1 => "0")
  TARGET_PROJECT = args[:targetPrj]
  TEST_SW = args[:emcTest]
  makeApp(t)
end

If I call rake task1[TARGET _1] everything is OK, but if I add second parameter rake task1[TARGET _1, 5] then I get:

Rake aborted!
Don't know how to build task task1[TARGET_1, '

I really do not know what is wrong?

2

There are 2 best solutions below

0
Aleksei Matiushkin On

The parameters should be separated by commas without spaces:

task1[TARGET_1,5]
0
Stefan On

Command line arguments are separated by spaces and rake treats each argument as a separate task. This would run tasks foo and bar:

rake foo bar

If you have:

rake task1[TARGET_1, 5]

then rake gets two arguments: task1[TARGET_1, and 5]. Trying to parse these strings results in an error.

To get the correct result, you can remove the space, escape the space, or put the argument in quotes:

rake task1[TARGET_1,5]
rake task1[TARGET_1,\ 5]
rake "task1[TARGET_1, 5]"

Note that this behavior isn't rake specific, that's how command line arguments work in general.