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
|
# File 'lib/git-object-browser/main.rb', line 4
def execute
host = '127.0.0.1'
port = 8080
dump = nil
step = nil
diff_dir = nil
nextstep = false
opts = OptionParser.new do |opts|
opts.on('-p', '--port PORT', 'port number') do |value|
port = value.to_i if 0 < value.to_i
end
opts.on('-b', '--bind HOST', 'address to bind') do |value|
host = value
end
opts.on('-d', '--dump PATH', 'dump .git as JSON and HTMLs') do |value|
dump = value
end
opts.on('--step STEP', 'dump JSONs into sub directory') do |value|
step = value
end
opts.on('--diff OLD_JSON_DIR', 'dump JSONs with diff data') do |value|
diff_dir = value
end
opts.on('--next', 'same with --step step${N} --diff step${N-1}') do |value|
nextstep = true
end
opts.on_tail("-h", "--help", "show this help.") do
puts opts
exit
end
opts.on_tail("-v", "--version", "show version.") do
puts "git-object-browser " + VERSION
exit
end
opts.parse!(ARGV)
end
target = find_target(ARGV[0])
if dump.nil?
GitObjectBrowser::Server::Main.execute(target, host, port)
else
if nextstep
step = :next
diff_dir = nil
end
GitObjectBrowser::Dumper::Main.execute(target, dump, step, diff_dir)
end
end
|