Added debug start option
This commit is contained in:
parent
5b4363b450
commit
8b5ecd9a8a
@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|||||||
s.email = ['thibaud@thibaud.me']
|
s.email = ['thibaud@thibaud.me']
|
||||||
s.homepage = 'http://rubygems.org/gems/guard'
|
s.homepage = 'http://rubygems.org/gems/guard'
|
||||||
s.summary = 'Guard keep an eye on your files modifications.'
|
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.required_rubygems_version = '>= 1.3.6'
|
||||||
s.rubyforge_project = 'guard'
|
s.rubyforge_project = 'guard'
|
||||||
|
@ -47,17 +47,19 @@ module Guard
|
|||||||
require "guard/#{name.downcase}"
|
require "guard/#{name.downcase}"
|
||||||
guard_class = ObjectSpace.each_object(Class).detect { |c| c.to_s.downcase.match "^guard::#{name.downcase}" }
|
guard_class = ObjectSpace.each_object(Class).detect { |c| c.to_s.downcase.match "^guard::#{name.downcase}" }
|
||||||
rescue LoadError
|
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
|
end
|
||||||
|
|
||||||
def locate_guard(name)
|
def locate_guard(name)
|
||||||
spec = Bundler.load.specs.find{|s| s.name == "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
|
spec.full_gem_path
|
||||||
|
rescue
|
||||||
|
UI.error "Could not find gem 'guard-#{name}' in the current Gemfile."
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
listener.stop
|
listener.stop
|
||||||
|
UI.clear if options[:clear]
|
||||||
yield
|
yield
|
||||||
listener.start
|
listener.start
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,8 @@ module Guard
|
|||||||
default_task :start
|
default_task :start
|
||||||
|
|
||||||
desc "start", "Starts guard"
|
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
|
def start
|
||||||
::Guard.start(options)
|
::Guard.start(options)
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ module Guard
|
|||||||
Signal.trap('INT') do
|
Signal.trap('INT') do
|
||||||
::Guard.listener.stop
|
::Guard.listener.stop
|
||||||
if ::Guard.guards.all?(&:stop)
|
if ::Guard.guards.all?(&:stop)
|
||||||
UI.info "Bye bye...", :reset => true, :clear => false
|
UI.info "Bye bye...", :reset => true
|
||||||
abort("\n")
|
abort("\n")
|
||||||
else
|
else
|
||||||
::Guard.listener.start
|
::Guard.listener.start
|
||||||
|
@ -5,7 +5,6 @@ module Guard
|
|||||||
def info(message, options = {})
|
def info(message, options = {})
|
||||||
unless ENV["GUARD_ENV"] == "test"
|
unless ENV["GUARD_ENV"] == "test"
|
||||||
reset_line if options[:reset]
|
reset_line if options[:reset]
|
||||||
clear if options.key?(:clear) ? options[:clear] : (::Guard.options && ::Guard.options[:clear])
|
|
||||||
puts reset_color(message) if message != ''
|
puts reset_color(message) if message != ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -14,16 +13,22 @@ module Guard
|
|||||||
puts "ERROR: #{message}"
|
puts "ERROR: #{message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def debug(message)
|
||||||
|
unless ENV["GUARD_ENV"] == "test"
|
||||||
|
puts "DEBUG: #{message}" if ::Guard.options && ::Guard.options[:debug]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def reset_line
|
def reset_line
|
||||||
print "\r\e "
|
print "\r\e "
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def clear
|
def clear
|
||||||
system("clear;")
|
system("clear;")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def reset_color(text)
|
def reset_color(text)
|
||||||
color(text, "\e[0m")
|
color(text, "\e[0m")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user