module Middleman::Guard

def self.add_guard(&block)

def self.add_guard(&block)
  @additional_guards ||= []
  @additional_guards << block
end

def self.start(options={}, livereload={})

def self.start(options={}, livereload={})
  options_hash = ""
  options.each do |k,v|
    options_hash << ", :#{k} => '#{v}'"
  end

  guardfile_contents = %Q{
    guard 'middleman'#{options_hash} do 
      watch("config.rb")
      watch(%r{^lib/^[^\.](.*)\.rb$})
    end
  }

  (@additional_guards || []).each do |block|
    result = block.call(options, livereload)
    guardfile_contents << result unless result.nil?
  end

  ::Guard.start({ :guardfile_contents => guardfile_contents })
end