Class: Nutella::Install

Inherits:
Command show all
Defined in:
lib/core/commands/install.rb

Instance Method Summary collapse

Instance Method Details

#run(args = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/core/commands/install.rb', line 11

def run(args=nil)
  # Is current directory a nutella prj?
  return unless Nutella.current_project.exist?

  # Check args
  if args.empty?
    console.warn 'You need to specify a template name, directory or URL'
    return
  end
  template = args[0]
  destination_dir = args.length==2 ? args[1] : nil
  
  # Extract project directory
  prj_dir = Nutella.current_project.dir

  # What kind of template are we handling?
  if is_template_a_local_dir? template
    add_local_template( template, template, prj_dir, destination_dir )
  elsif is_template_a_git_repo? template
    add_remote_template( template, prj_dir, destination_dir)
  elsif is_template_in_db? template
    add_central_template( template, prj_dir, destination_dir)
  else
    console.warn 'The specified template is not a valid nutella template'
  end
  
end