Added debug start option

This commit is contained in:
Thibaud Guillaume-Gentil 2010-10-10 12:38:25 +02:00
parent 5b4363b450
commit 8b5ecd9a8a
5 changed files with 16 additions and 8 deletions

View File

@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.email = ['thibaud@thibaud.me']
s.homepage = 'http://rubygems.org/gems/guard'
s.summary = 'Guard keep an eye on your files modifications.'
s.description = 'Guard is a command line tool to easly handle events on files modifications.'
s.description = 'Guard is a command line tool to easily handle events on files modifications.'
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = 'guard'

View File

@ -47,17 +47,19 @@ module Guard
require "guard/#{name.downcase}"
guard_class = ObjectSpace.each_object(Class).detect { |c| c.to_s.downcase.match "^guard::#{name.downcase}" }
rescue LoadError
UI.error "#{name} guard gem not found, try to add it to your Gemfile."
UI.error "Could not find gem 'guard-#{name}' in the current Gemfile."
end
def locate_guard(name)
spec = Bundler.load.specs.find{|s| s.name == "guard-#{name}" }
UI.error "Could not find gem '#{name}' in the current Gemfile." unless spec
spec.full_gem_path
rescue
UI.error "Could not find gem 'guard-#{name}' in the current Gemfile."
end
def run
listener.stop
UI.clear if options[:clear]
yield
listener.start
end

View File

@ -6,7 +6,8 @@ module Guard
default_task :start
desc "start", "Starts guard"
method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell after each change"
method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell before each change/run_all/reload"
method_option :debug, :type => :boolean, :default => false, :aliases => '-d', :banner => "Print debug messages"
def start
::Guard.start(options)
end

View File

@ -13,7 +13,7 @@ module Guard
Signal.trap('INT') do
::Guard.listener.stop
if ::Guard.guards.all?(&:stop)
UI.info "Bye bye...", :reset => true, :clear => false
UI.info "Bye bye...", :reset => true
abort("\n")
else
::Guard.listener.start

View File

@ -5,7 +5,6 @@ module Guard
def info(message, options = {})
unless ENV["GUARD_ENV"] == "test"
reset_line if options[:reset]
clear if options.key?(:clear) ? options[:clear] : (::Guard.options && ::Guard.options[:clear])
puts reset_color(message) if message != ''
end
end
@ -14,16 +13,22 @@ module Guard
puts "ERROR: #{message}"
end
def debug(message)
unless ENV["GUARD_ENV"] == "test"
puts "DEBUG: #{message}" if ::Guard.options && ::Guard.options[:debug]
end
end
def reset_line
print "\r\e "
end
private
def clear
system("clear;")
end
private
def reset_color(text)
color(text, "\e[0m")
end