# encoding: utf-8 module LocalPac module Actions class CreateRepository private attr_reader :vcs_engine, :path, :options public def initialize(path, options = {}, vcs_engine = LocalPac::Git) @path = path @options = options @vcs_engine = vcs_engine end def run if need_to_run? || options[:force] == true LocalPac.ui_logger.warn "Creating repository \"#{path}\"." if options[:bare] == true vcs_engine.init(path, true) else vcs_engine.init(path) end else LocalPac.ui_logger.warn "Repository \"#{path}\" already exists. Do not create it again!." end end private def need_to_run? !File.exists?(path) end end end end