From: "shyouhei (Shyouhei Urabe)" Date: 2012-11-22T10:25:53+09:00 Subject: [ruby-core:49838] [ruby-trunk - Feature #5010] Add Slop(-like) in stdlib and deprecate current OptionParser API Issue #5010 has been updated by shyouhei (Shyouhei Urabe). What made this thread long was the request to deprecate optparse, I think. No one is arguing about its lacking documents, being non-intuitive, being not cool modern sexy urbane taste, and so on. And no one is arguing that other libs (like Slop) have metits. That said, to deprecate something is still a hard job. You need a good reason to remove it, not just because it is broken (if it is why not just fix). And I think I have not yet heard about that. Why you think we should abandon optparse? You can't have 128 different option parser standard libs at once, doesn't mean you should have zero standard lib. Right? ---------------------------------------- Feature #5010: Add Slop(-like) in stdlib and deprecate current OptionParser API https://bugs.ruby-lang.org/issues/5010#change-33423 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 :
  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
This is the equivalent in Slop:
require 'slop'

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

p opts.to_hash
-- http://bugs.ruby-lang.org/