How do I get only long options work in OptionParser in Ruby?
optionparser, ruby
Solution
I found the code which causes this behavior, in `optparse.rb`, lines 1378-1380:
# if no short options match, try completion with long
# options.
sw, = complete(:long, opt)
If you don't like that behavior, it seems your best option is to create a copy of `optparse.rb` within your project, remove the offending `rescue InvalidOption` clause within the copy, and `load` that rather than the standard library's version.
Problem
I have such a simple code in Ruby (test.rb): ``` #! /usr/bin/env ruby require 'optparse' OptionParser.new do |option| option.on("--sort", "Sort data") do puts "--sort passed" end end.parse! ``` then I run it: `./test.rb -s` and got: ``` --sort passed ``` Have I missed something? I want the only `--sort` (long) option works, not the short one. How do I get it?