Issue #5010 has been updated by duerst (Martin Dürst).


trans (Thomas Sawyer) wrote:
> @duerst
> >I agree with Rodrigo. If I have to use an option parser, I don't want to 
> > waste time shopping around.
> >
> > Also, if no option parser outside optparse gets significant traction 
> > outside the Ruby standard library, this means that none of them is 
> > significantly better than the current one for a significant percentage 
> > of Ruby users.
>  
> You just contradicted yourself.

Can you explain? The fact that I'm not interested in wasting time shopping around doesn't mean that others won't do that if they meet problems with the current ones in the standard library or are otherwise interested in something better.

> And your first argument is exactly the problem with Ruby rubber stamping an official option parser.

Anybody can use any option parser they want. Ruby already has two. Ruby isn't rubber stamping, but just providing something for those who don't want to shop around and deal with the hassles of installation. Even if the two currently in Ruby are not perfect, they may be good enough. And they were available at a time when the more modern ones were not yet available. Anyway, the fact that there are so many out there seems to indicate to me that it's too early for Ruby to pick up a third one, or replace one of the existing ones in the standard library.
----------------------------------------
Feature #5010: Add Slop(-like) in stdlib and deprecate current OptionParser API
https://bugs.ruby-lang.org/issues/5010#change-33463

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/