def setup(options = {})
@running = true
@lock = Mutex.new
@options = options.dup
@watchdir = (options[:watchdir] && File.expand_path(options[:watchdir])) || Dir.pwd
@runner = ::Guard::Runner.new
@scope = { :plugins => [], :groups => [] }
if options[:debug]
Thread.abort_on_exception = true
::Guard::UI.options[:level] = :debug
debug_command_execution
end
::Guard::UI.clear(:force => true)
deprecated_options_warning
setup_groups
setup_guards
setup_listener
setup_signal_traps
::Guard::Dsl.evaluate_guardfile(options)
::Guard::UI.error 'No guards found in Guardfile, please add at least one.' if @guards.empty?
if @options[:group]
@scope[:groups] = @options[:group].map { |g| ::Guard.groups(g) }
end
if @options[:plugin]
@scope[:plugins] = @options[:plugin].map { |p| ::Guard.guards(p) }
end
runner.deprecation_warning if @options[:show_deprecations]
setup_notifier
setup_interactor
self
end