Freelance developer, and designer

Much More Elegant Rake Arguments

Here's a basic hack to perform Rake tasks more... elegantly. I got it from it { should be_useful }.

Basically, to not use

rake create FILE=user


rake create[user]

and have this instead:

rake create user

Which is much more elegant if I may say so myself. We override the task name in our rake file like this:

task :create do |task, args|
    filename = ARGV.last
    filename.to_sym do ; end

That's about it! I guess if we want more parameters, we'll loop and override each one. Excluding the current task of course!