Perhaps a quick look at the (somewhat confusing) documentation would shed some light on the situation. If you look at the docs, you'll end up at OptionParser#make_switch
where you'll find an explanation of what the opt.on
arguments look like:
Long style switch:
Specifies a long style switch which takes a mandatory, optional or no argument. It’s a string of the following form:"--switch=MANDATORY" or "--switch MANDATORY" "--switch[=OPTIONAL]" "--switch"
Short style switch:
Specifies short style switch which takes a mandatory, optional or no argument. It’s a string of the following form:"-xMANDATORY" "-x[OPTIONAL]" "-x"
Note the -xMANDATORY
and then look closer at your @opts.on
call:
@opts.on( '-?', '-help','Show this message') do
# ---------------^^^^^
That -help
defines a -h
option with a required elp
argument. Presumably the option parser is interpreting that to mean that -h
is an alias for -?
and since -h
is defined with a required argument, -?
also requires an argument. If you use --help
(i.e. a long style switch) then you'll probably have a better time:
@opts.on('-?', '--help', 'Show this message') do
I working from the Ruby 2.0 version but I doubt much has changed in the option parser since the older version of Ruby that you appear to be using.