Issue #5010 has been updated by trans (Thomas Sawyer).


I actually think it would be better to remove the option parser libraries from Ruby's stdlib alltogther. There are a number of really good option parser gems out there, but they get little use b/c developers tend to "play it safe" and use the built-in library even if it is less optimal then a 3rd party gem. This in turns hurts the option parser "market" b/c developers aren't putting the available libraries to the test, nor submitting bug reports or patches to improve them. Remove the standard libs and we'd see this area of API development flourish.

----------------------------------------
Feature #5010: Add Slop(-like) in stdlib and deprecate current OptionParser API
https://bugs.ruby-lang.org/issues/5010#change-33249

Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Assigned
Priority: Low
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: next minor


I always found the OptionParser API not as well designed as it could be.

I've just found this gem:

http://lee.jarvis.co/slop/

Much better API and I think we should integrate it to Ruby 2.0.

Take a look at the minimal example shown in OptionParser :

<pre>
  require 'optparse'

  options = {}
  OptionParser.new do |opts|
    opts.banner = "Usage: example.rb [options]"

    opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
      options[:verbose] = v
    end
  end.parse!

  p options
  p ARGV
</pre>

This is the equivalent in Slop:

<pre>
require 'slop'

opts = Slop.parse do
  banner "Usage: example.rb [options]"
  on :v, :verbose, "Run verbosely", :default => true
end

p opts.to_hash
</pre>


-- 
http://bugs.ruby-lang.org/