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
|
# File 'lib/msgpack/inspect/command.rb', line 8
def self.execute(argv)
format = :yaml
opts = OptionParser.new
opts.banner = "Usage: msgpack-inspect [options] FILE"
opts.separator ""
opts.separator "Options:"
opts.separator ""
opts.on("-f", "--format FORMAT", "output format of inspection result (#{MessagePack::Inspect::FORMATS.compact.join('/')}) [default: yaml]") do |v|
format = v.to_sym
end
opts.on("-r", "--require LIB", "ruby file path to require (to load ext type definitions)") do |path|
require path
end
opts.on("-v", "--version", "Show version of this software") do
puts "msgpack-inspect #{MessagePack::Inspect::VERSION}"
exit
end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
opts.parse!(argv)
filename = argv.first
io = if filename == '-'
STDIN.binmode
else
File.open(filename).binmode
end
unless MessagePack::Inspect::FORMATS.include?(format)
puts opts
puts "Unsupported format: #{format}"
exit 1
end
puts MessagePack::Inspect.inspect(io, format)
end
|