From: "trans (Thomas Sawyer)" Date: 2012-11-22T03:11:46+09:00 Subject: [ruby-core:49826] [ruby-trunk - Feature #5010] Add Slop(-like) in stdlib and deprecate current OptionParser API Issue #5010 has been updated by trans (Thomas Sawyer). @shyouhei > I don't like this shit let's just remove" doesn't sound productive to me. No one said that. > Is it hard to make it better instead? Hmmm... seems to me I tried that once. It was rejected. Unfortunately it was so long ago now I can't find anything about it. But in any case I think it's missing the point. For who's to say what the best option parser is? There isn't just one perfect parser out there that if we all just work together we can pull down from the world of perfect forms. There are all sorts of approaches: We have very simple mechanisms like CLAP, traditional systems like getoptlong and optparse, "on steroids" variations of those like slop and trollop, DSLs like thor and even command to object mappings like executable. All of these have various merits, and might be more suitable to one application or one developer's way thinking. That's why I think it is better to encourage diversity (as matz said in his last keynote), rather than try to lock Ruby further into a "one right way". ---------------------------------------- Feature #5010: Add Slop(-like) in stdlib and deprecate current OptionParser API https://bugs.ruby-lang.org/issues/5010#change-33411 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/