16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/iot/new.rb', line 16
def new project_path
if project_path.empty?
puts "No value provided for required arguments 'app_path'"
return
end
if File.exist? project_path
puts "#{project_path} already exists"
return
end
project_path = File.expand_path project_path
Dir.mkdir project_path
Dir.mkdir "#{project_path}/#{Iot_dir}"
init_files = [
"Makefile",
"main.cpp",
"ble.yml",
"#{Iot_dir}/STService.h",
"#{Iot_dir}/STBLEdevice.h",
"#{Iot_dir}/STDeviceInfo.h"
]
template_files = [
Template_makefile,
Template_main,
Template_bleyaml,
Template_stservice,
Template_stbledevice,
Template_stdeviceinfo
]
count = 0
init_files.each do |init_file|
File.open("#{project_path}/#{init_file}", "w") do |file|
file.puts template_files[count]
count += 1
end
end
end
|