62.5.5. Analýza argumentů programu
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
opts.each do |opt, arg|
if (if print "2 Help\n"
end)
print "1 Help\n"
end
puts "Option: #{opt}, arg #{arg}"
end
puts "Remaining args: #{ARGV.join(', ')}"
% ruby test.rb -h