1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Add support for running the executables in Ruby without exiting.

This commit is contained in:
Nathan Weizenbaum 2010-04-10 13:19:10 -07:00
parent ab289bd9e9
commit 002de89b3a

View file

@ -15,14 +15,11 @@ module Haml
# Parses the command-line arguments and runs the executable.
# Calls `Kernel#exit` at the end, so it never returns.
#
# @see #parse
def parse!
begin
@opts = OptionParser.new(&method(:set_opts))
@opts.parse!(@args)
process_result
@options
parse
rescue Exception => e
raise e if @options[:trace] || e.is_a?(SystemExit)
@ -32,6 +29,19 @@ module Haml
exit 0
end
# Parses the command-line arguments and runs the executable.
# This does not handle exceptions or exit the program.
#
# @see #parse!
def parse
@opts = OptionParser.new(&method(:set_opts))
@opts.parse!(@args)
process_result
@options
end
# @return [String] A description of the executable
def to_s
@opts.to_s