OptionParse with no arguments show banner
Just add the -h key to the ARGV, when it is empty, so you may to do something like this:
require 'optparse'
ARGV << '-h' if ARGV.empty?
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: calc.rb [options]"
opts.on("-l", "--length L", Integer, "Length") { |l| options[:length] = l }
opts.on("-w", "--width W", Integer, "Width") { |w| options[:width] = w }
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end.parse!