diff --git a/guard.gemspec b/guard.gemspec index 267cc70..6010728 100644 --- a/guard.gemspec +++ b/guard.gemspec @@ -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' diff --git a/lib/guard.rb b/lib/guard.rb index 95474b6..0df26bd 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -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 diff --git a/lib/guard/cli.rb b/lib/guard/cli.rb index 56f5098..bba9b82 100644 --- a/lib/guard/cli.rb +++ b/lib/guard/cli.rb @@ -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 diff --git a/lib/guard/interactor.rb b/lib/guard/interactor.rb index ef5fc39..d5e14e3 100644 --- a/lib/guard/interactor.rb +++ b/lib/guard/interactor.rb @@ -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 diff --git a/lib/guard/ui.rb b/lib/guard/ui.rb index 9491766..197b29d 100644 --- a/lib/guard/ui.rb +++ b/lib/guard/ui.rb @@ -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