Class: Escalator::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/escalator/cli.rb

Instance Method Summary collapse

Instance Method Details

#create(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/escalator/cli.rb', line 33

def create(name)
  if File.exist? name
    puts "ERROR: #{name} already exists."
    exit -1
  end

  # copy from template file
  root_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
  template_path = File.join(root_dir, "template", "escalator")
  cp_r template_path, name

  # copy plc directory
  temlate_plc_path = File.join(root_dir, "lib", "plc")
  cp_r temlate_plc_path, name
  # remove unnecessary file from plc directory
  %w(plc.rb emulator).each do |fn|
    rm_r File.join(name, "plc", fn)
  end
  puts "#{name} was successfully created."
end