Created
October 22, 2015 16:07
-
-
Save padde/4862b1a351aeabe9c8e8 to your computer and use it in GitHub Desktop.
Pass options hash to Rake
This file contains hidden or 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
module RakeOptionParser | |
def self.parse(args) | |
args.extras.each_with_object({}) do |arg, result| | |
key, value = arg.split(/:\s*/, 2) | |
result[key.to_sym] = value | |
end | |
end | |
end | |
namespace :foo do | |
task :bar, [] => :environment do |t, args| | |
options = RakeOptionParser.parse(args) | |
p options | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage