Passing Parameters to Child Tasks from a Parent Task in Rake

Posted by Haseeb Khan on Stack Overflow See other posts from Stack Overflow or by Haseeb Khan
Published on 2010-04-04T15:30:54Z Indexed on 2010/04/04 15:33 UTC
Read the original article Hit count: 445

Filed under:
|
|
|
|

I am new to the world of Rake and currently writing a Rake Script which consists of various tasks depending on the arguments passed to it on runtime.

From some Tutorials over the web, I figured out how to pass parameters to the Script as well how to make a task which is dependent on other subtasks.

For reference, I have mentioned a sample below:

task :parent, [:parent_argument1, :parent_argument2, :parent_argument3] => [:child1, :child2] do
  # Perform Parent Task Functionalities
end

task :child1, [:child1_argument1, :child1_argument2] do |t, args|
  # Perform Child1 Task Functionalities
end

task :child2, [:child2_argument1, :child2_argument2] do |t, args|
  # Perform Child2 Task Functionalities
end

Following is what I want to achieve:

  1. I want to pass the arguments passed to the parent task to the child tasks. Is it allowed?
  2. Is there a way I can make the child tasks as private so they can't be called independently?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about rake

Related posts about ruby