42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/treyja/exe.rb', line 42
def run
opts = OptionParser.new
opts.on("--output DIR")
opts.on("--normalize")
opts.on("--round INT")
opts.on("--version") do
puts "Version: #{Treyja::VERSION}"
return
end
opts.on("-h", "--help") do
Treyja::Command::Help.new.run
return
end
command, file = opts.parse!(@args, into: options)
patch_round options.fetch(:round, 4).to_f
case command
when "dump"
reader = Treyja::Reader.new file
Treyja::Command::Dump.new(reader).run
when "json"
reader = Treyja::Reader.new file
Treyja::Command::Json.new(reader).run
when "image"
output_dir = options[:output]
raise "--output option required" unless output_dir
reader = Treyja::Reader.new file
Treyja::Command::Image.new(reader, output_dir, options.slice(:normalize)).run
when "csv"
reader = Treyja::Reader.new file
Treyja::Command::Csv.new(reader).run
when nil
Treyja::Command::Help.new.run
else
puts "Unknown command: #{command}"
Treyja::Command::Help.new.run
end
end
|