filename = nil
lines = 0 # Default means no truncating
loop do
begin
opt, arg = gets
breakif not opt
case opt
when "-h"
puts "Usage: ..."
break # Stop processing if -h
when "-f"
filename = arg # Save the file argument
when "-l"
if arg != ""
lines = arg # Save lines arg (if given)
else
lines = 100 # Default for truncating
end
end
rescue => err
puts err
break
end
end
puts "filename = #{filename}"
puts "lines = #{lines}"