From: Lee Jarvis <ljjarvis@...>
Date: 2011-11-08T11:33:56+09:00
Subject: [ruby-core:40827] [ruby-trunk - Feature #5010] Add Slop(-like) in stdlib and deprecate current OptionParser API


Issue #5010 has been updated by Lee Jarvis.


Hi,

I'm the author behind Slop. Although I never considered Slop to ever hit Ruby trunk I of course think it's a great idea. That said, there's already two option parsing libraries in stdlib and I think adding another is just bloat. 

For those of you worried any instance_eval, it's completely optional. Slop also supports the following:

* Parsing an optspec: https://github.com/injekt/slop/wiki/Optspec 
* Auto creating options: https://github.com/injekt/slop/wiki/Auto-Create
* Commands (nested Slop instances): https://github.com/injekt/slop/wiki/Commands

And multiple methods of creating options: https://github.com/injekt/slop/wiki/Creating-Options

Slop is also very well documented and extremely well tested, and fits within a concise 500 or less LOC: https://github.com/injekt/slop

Again, I'm not so sure about integrating Slop into stdlib (I'd like my bug fixes and features changes instantly available to those who use my gem), but I wanted to clear up any concerns anyway.
----------------------------------------
Feature #5010: Add Slop(-like) in stdlib and deprecate current OptionParser API
http://redmine.ruby-lang.org/issues/5010

Author: Rodrigo Rosenfeld Rosas
Status: Open
Priority: Low
Assignee: Yukihiro Matsumoto
Category: 
Target version: 


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://redmine.ruby-lang.org