Thursday, December 18, 2008

Rake task with arguments or parameters

You want to pass arguments to a task in the Rakefile. This is how you define the task.

task :taskname, :arg1, :arg2 do|t, args|
p "Executing task #{t} with Argument #{args.arg1} and #{args.arg2}"
end



You invoke the task as follows

rake taskname[arg1,arg2]
(Not that there is no space between the arguments)

OR

rake taskname"[arg1, arg2]"
(Note space between arguments is ok here.