Created
May 7, 2010 16:36
-
-
Save joonyou/393687 to your computer and use it in GitHub Desktop.
passing in arguments in rake task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "my task do something" | |
task :do_something => :environment do | |
options = {} | |
$*.each {|arg| options[arg.split(":")[0]] = arg.split(":")[1]} | |
options.reject! {|k,v| v == "" || v.nil? } | |
# I now have {"setting" => "WHATEVER", "user" => "me"} | |
# for whatever I want to do. | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment