I just started using ruby and I've been following the online book at
rubycentral as well as the Ruby reference manual.
Most of this code is taken from the online book.
opts = GetoptLong.new(
[ "--referer", "-f", GetoptLong::REQUIRED_ARGUMENT ],
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
[ "--images", "-i", GetoptLong::REQUIRED_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
opts.each do |opt, arg|
print "1 Help\n" if #{opt} =~ "help"
if #{opt} =~ "help"
print "2 Help\n"
end
puts "Option: #{opt}, arg #{arg}"
end
puts "Remaining args: #{ARGV.join(', ')}"
% ruby test.rb -h
2 Help
Option: --help, arg
Remaining args:
Why is "1 Help" not printed out? Am I missing something obvious?