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?
In that case you can pass an array of valid arguments to your option:
Usage:
Note that you can still use the shorthand
-s
: