-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincludeTree.rb
More file actions
55 lines (46 loc) · 1.21 KB
/
includeTree.rb
File metadata and controls
55 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "find"
require_relative "Config.rb"
require_relative "IncludeList.rb"
require_relative "PaserInfo.rb"
require_relative "Utils.rb"
class IncludeTree
def initialize(config)
@config = config
@list = IncludeList.new(config.include_search_path)
end
def paser()
outList = getfiles.map{ |file| PaserInfo.new(file, @list) }
output(outList)
end
private
def getfiles
matcher = @config.getMatcher
return Find.find(@config.search_path).select{ |file| matcher.include(file) }
end
def output(outList)
dst = File.new(@config.output_path, "w+")
list = outList.sort do |a, b|
a.sum <=> b.sum
end
list.each {|cpp| cpp.output(dst)}
dst.close
end
end
$paser = lambda{|| IncludeTree.new(IncludeTreeConfig.new).paser}
$help = lambda{|| p "this is a help"}
options = {"help:"=>["give how to use", $help],
"paser"=> ["paser the file config in the config file", $paser]}
ARGV.each do |arg|
if options.each_key.include?(arg)
options[arg][1].call
else
p "#{arg} is not define in list"
end
end
if(ARGV.empty? )
p "Follow option is provided"
options.each do |var|
p "#{var[0]} : #{var[1][0]} "
end
end
puts "====Current input arg is #{ARGV}===="