Confuse with OptionParser -h opinion

require ‘optparse’

options = {}

optparse = OptionParser.new do|opts|
opts.banner = “Usage: file1 file2 …”
opts.on( ‘-r’, ‘–hhhh’, ‘screen’ ) do
puts opts
end

opts.on( ‘-s’, ‘–ssss’, ‘Display this screen’ ) do
puts opts
end

opts.parse!
end

=======
[email protected]:~$ ruby xb.rb -h
Usage: file1 file2 …
-r, --hhhh screen
-s, --ssss Display this screen

I use -h opinion, then it put out all opinion. but -h opinion doesn’t
exit.
why this happened? can someone penlight me?

2009/10/12 Zhenning G. [email protected]:

opts.on( ‘-s’, ‘–ssss’, ‘Display this screen’ ) do
-s, --ssss Display this screen

I use -h opinion, then it put out all opinion. but -h opinion doesn’t
exit.
why this happened? can someone penlight me?

Someone else defined it for you

11:17:16 desktop$ ruby19 -r optparse -e ’ OptionParser.new.parse “-h”’
Usage: -e [options]
11:17:42 desktop$ ruby19 -r optparse -e ’ OptionParser.new.parse “-x”’
-e:1:in `’: invalid option: -x (OptionParser::InvalidOption)

Kind regards

robert

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs