public
Last active

example arg pasing in rake

  • Download Gist
Rakefile
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
desc 'shortcut to do:dev'
task :do => 'do:dev'
 
namespace :do do
FileList["#{CONFIG_DIR}/*.json"].each do |f|
target = File.basename(f, '.*')
 
desc "do stuff for #{target}"
task target do
Rake::Task['do:stuff'].invoke(target)
end
end
 
task :junk, :target do |t, args|
puts "doing junk first"
puts args.inspect
end
 
task :otherstuff, :target do |t, args|
puts "doing otherstuff"
puts args.inspect
end
 
task :stuff, [:target] => [:junk] do |t, args|
target = args.target
puts "doing stuff"
puts args.inspect
Rake::Task['do:otherstuff'].invoke(target)
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.