I want to create a rake task that takes one parameter with no argument.
task :mytask => :environment do
  options = Hash.new
  OptionParser.new do |opts|
    opts.on('-l', '--local', 'Run locally') do
      options[:local] = true
    end
  end.parse!
  # some code
end
But it throws:
$ rake mytask -l
rake aborted!
OptionParser::MissingArgument: missing argument: -l
Meanwhile:
$ rake mytask -l random_arg
ready
Why?
- Rake 10.4.2
- jruby 1.7.13
 
    