Changes to make the command-line tool more testable.

This commit is contained in:
Chris Eppstein 2009-01-19 07:52:39 -08:00
parent 5fce487ba8
commit ff2a54af53
2 changed files with 8 additions and 5 deletions

View File

@ -5,4 +5,4 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass', 'exec'))
command = Compass::Exec::Compass.new(ARGV)
command.run!
exit command.run!

View File

@ -37,11 +37,11 @@ module Compass
def initialize(args)
self.args = args
self.options = {}
parse!
end
def run!
begin
parse!
perform!
rescue Exception => e
raise e if e.is_a? SystemExit
@ -50,9 +50,9 @@ module Compass
else
::Compass::Exec.report_error(e, @options)
end
exit 1
return 1
end
exit 0
return 0
end
protected
@ -165,7 +165,6 @@ END
end
def do_command(command)
require File.join(File.dirname(__FILE__), 'commands', command.to_s)
command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
command_class = eval("::Compass::Commands::#{command_class_name}")
command_class.new(Dir.getwd, options).perform
@ -174,3 +173,7 @@ END
end
end
end
Dir.glob(File.join(File.dirname(__FILE__), 'commands', "*.rb")).each do |file|
require file
end