Skip to main content
added 257 characters in body
Source Link
jassa
  • 20.2k
  • 4
  • 29
  • 25

I just wanted to be able to run:

$ rake some:task arg1 arg2 

Simple, right? (Nope!)

Rake interprets arg1 and arg2 as tasks, and tries to run them. So we just abort before it does.

namespace :some do task task: :environment do arg1, arg2 = ARGV # your task... exit end end 

Take that, brackets!

Disclaimer: I wanted to be able to do this in a pretty small pet project. Not intended for "real world" usage since you lose the ability to chain rake tasks (i.e. rake task1 task2 task3). IMO not worth it. Just use the ugly rake task[arg1,arg2].

I just wanted to be able to run:

$ rake some:task arg1 arg2 

Simple, right? (Nope!)

Rake interprets arg1 and arg2 as tasks, and tries to run them. So we just abort before it does.

namespace :some do task task: :environment do arg1, arg2 = ARGV # your task... exit end end 

Take that, brackets!

I just wanted to be able to run:

$ rake some:task arg1 arg2 

Simple, right? (Nope!)

Rake interprets arg1 and arg2 as tasks, and tries to run them. So we just abort before it does.

namespace :some do task task: :environment do arg1, arg2 = ARGV # your task... exit end end 

Take that, brackets!

Disclaimer: I wanted to be able to do this in a pretty small pet project. Not intended for "real world" usage since you lose the ability to chain rake tasks (i.e. rake task1 task2 task3). IMO not worth it. Just use the ugly rake task[arg1,arg2].

Source Link
jassa
  • 20.2k
  • 4
  • 29
  • 25

I just wanted to be able to run:

$ rake some:task arg1 arg2 

Simple, right? (Nope!)

Rake interprets arg1 and arg2 as tasks, and tries to run them. So we just abort before it does.

namespace :some do task task: :environment do arg1, arg2 = ARGV # your task... exit end end 

Take that, brackets!