Issue #5010 has been updated by jonforums (Jon Forums).


> ...rather than try to lock Ruby further into a "one right way".

Use an existing alternative or roll your own if you don't like ruby's (needed) baseline impl. The situation is not even remotely close to lock-in.

This discussion smells like what may have occurred in Python. They weren't able to find a backwards compatible update to optparse and ended up with argparse-using-deprecated-but-still-supported-optparse. I believe Python now has *3* option parsers in stdlib.

  http://www.doughellmann.com/PyMOTW/argparse/

Perhaps it made sense for Python given it's realities (i.e. easy_install/distribute/pip vs. rubygems), but if this request is going to compete for limited ruby-core committer time, I agree with Magnus. 

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

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/