module Optimist
def die(arg, msg = nil, error_code = nil)
#
# An exit code can be provide if needed
#
# Optimist::die "need at least one filename" if ARGV.empty?
#
# end
# opt :whatever # ...
# options do
#
# about -h, and die. Example:
# In the one-argument case, simply print that message, a notice
#
# die :volume, "too soft" if opts[:volume] < 0.1
# die :volume, "too loud" if opts[:volume] > 10.0
#
# end
# opt :volume, :default => 0.0
# options do
#
# 'msg', and dies. Example:
# Informs the user that their usage of 'arg' was wrong, as detailed by
def die(arg, msg = nil, error_code = nil) if @last_parser @last_parser.die arg, msg, error_code else raise ArgumentError, "Optimist::die can only be called after Optimist::options" end end