1 EosHome = ENV["EOS_HOME"]
2 EosSrc = EosHome + "/src/Tools/"
3 JSONDirPath = ENV["ZEPHYR_HOME"] + "/user-specific-files/OptionControlFile/"
4 CommandOptionPath = JSONDirPath + "commands/"
5 CommandListPath = JSONDirPath + "command_list.json"
6 TagListPath = JSONDirPath + "tag_list.json"
7 ErrorLogPath = JSONDirPath + "error_log.json"
9 require ENV["ZEPHYR_HOME"] + "/cli/lib/option"
13 command_lists = Array.new
14 class_names = Dir.glob("#{EosSrc}*").sort
18 if !(Dir.exist?(JSONDirPath))
19 Dir.mkdir(JSONDirPath, 0755)
22 if !(Dir.exist?(JSONDirPath + 'commands/'))
23 Dir.mkdir(JSONDirPath + 'commands/', 0755)
29 class_names.each do |class_path|
30 class_name = File.basename(class_path)
32 if (class_name == "Makefie" ||
33 class_name == "Makefile.orig" ||
34 class_name == "Config") then
38 command_names = Dir.glob("#{class_path}/*").sort
40 command_names.each do |command_path|
41 command_name = File.basename(command_path)
42 if (command_name=="Makefile"||
43 command_name=="Makefile.orig"||
44 command_name=="Config"
45 command_name == "Makefile.org" ||
46 command_name == "q") then
50 #success Hash {option->option ,tag->tag}
51 #error Array [option_path,ex.class]
53 #create_json_file.rbとoption.rbを書き換える
54 result = Option.csv2hash(command_path)
57 if result.class.to_s == "Hash"
59 option = result[:option]
60 json_name = CommandOptionPath + "#{command_name}.json"
61 json = JSON.pretty_generate(option)
63 #write to ~/json/option/
64 open(json_name,"w") do |fh|
68 #prepare for ~/json/command_list.json
70 tmp[:name] = command_name
71 tmp[:tags] = Array.new
72 tmp[:tags].push("all")
73 tmp[:tags].push(class_name)
74 command_lists.push(tmp)
76 if !tag_list.include?(class_name)
77 tag_list.push(class_name)
80 elsif result.class.to_s == "Array"
82 error["path"] = result[0]
83 error["error"] = result[1]
84 error_logs[command_name] = error
86 print "Unexpected Error Occured!\n"
92 #Write to ~/json/command_list.json
93 json = JSON.pretty_generate(command_lists)
94 open(CommandListPath,"w") do |fh|
98 #Write to ~/json/error_log.json
99 json = JSON.pretty_generate(error_logs)
100 open(ErrorLogPath,"w") do |fh|
104 ##write to ~/json/tag_list.json
105 json = JSON.pretty_generate(tag_list)
106 open(TagListPath,"w") do |fh|