Reffering that answer I was trying to use OptionParser
to parse rake
arguments. I simplified example from there and I had to add two ARGV.shi
You can use the method OptionParser#order!
which returns ARGV without the wrong arguments:
options = {}
o = OptionParser.new
o.banner = "Usage: rake user:create [options]"
o.on("-u NAME", "--user NAME") { |username|
options[:user] = username
}
args = o.order!(ARGV) {}
o.parse!(args)
puts "user: #{options[:user]}"
You can pass args like that: $ rake foo:bar -- '--user=john'