Class: LadderDrive::CLI
- Inherits:
-
Thor
- Object
- Thor
- LadderDrive::CLI
- Defined in:
- lib/ladder_drive/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/ladder_drive/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.(File.join(File.dirname(__FILE__), "..", "..")) template_path = File.join(root_dir, "template", "ladder_drive") 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 |
#plugin(name) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ladder_drive/cli.rb', line 55 def plugin(name) root_dir = File.(File.join(File.dirname(__FILE__), "..", "..")) # copy plugin plugins_dir = File.join(root_dir, "plugins") plugin_path = File.join(plugins_dir, "#{name}_plugin.rb") if File.exist? plugin_path mkdir_p "plugins" cp plugin_path, "plugins/#{name}_plugin.rb" end # copy sample settings config_dir = File.join(plugins_dir, "config") config_path = File.join(config_dir, "#{name}.yaml.example") if File.exist? config_path dst_dir = "config/plugins" mkdir_p dst_dir dst_path = "config/plugins/#{name}.yaml.example" cp config_path, dst_path unless File.exist? dst_path end end |