Method: Docman::CLI#init

Defined in:
lib/docman/cli.rb

#init(name, repo) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/docman/cli.rb', line 14

def init(name, repo)
  if File.directory? name
    say("Directory #{name} already exists")
    if options[:force]
      FileUtils.rm_r(name)
    elsif options[:skip]
     if File.directory? File.join(name, 'config') and GitUtil.repo? File.join(name, 'config')
       return
     else
       FileUtils.rm_r(name)
     end
    else
      choice = ask('Are you sure you want do delete existing docroot? Type "yes" if you agree.')
      if choice == 'yes'
        FileUtils.rm_r(name)
      elsif
      Kernel::abort 'Exit'
      end
    end
  end

  puts "Init docroot directory #{name} and retrieve config from provided repo."
  Application.instance.init(name, repo, options)
  say('Complete!', :green)
end