rake 带参数就这么做

Posted: May 17, 2011 in Ruby
Tags: ,
task :t1, :a1, :a2, :needs => [:t2, :t3] do |t, args|
  args.with_defaults(:a1 => 'default_1 in task t1', :a2 => 'default_2 in task t1')
  puts t.name
  puts args
end

task :t2, :a1, :a2 do |t, args|
  args.with_defaults(:a1 => 'default_1 in task t2', :a2 => 'default_2 in task t2')
  puts "this is t2"
  puts args
end

task :t3, :a1, :a2 do |t, args|
  args.with_defaults(:a1 => 'default_1 in task t3', :a2 => 'default_2 in task t3')
  puts "this is t3"
end

可以执行rake t1[1,2]或者rake t1试试

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s