Class: PerfMonger::Command::PlayCommand
Instance Method Summary
collapse
Methods inherited from BaseCommand
register_alias, register_command
Constructor Details
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/perfmonger/command/play.rb', line 11
def initialize
@parser = OptionParser.new
@parser.banner = "Usage: perfmonger play [options] LOG_FILE\n\nOptions:\n"
@color = false
@parser.on("-c", "--color", "Use colored JSON ouptut") do
@color = true
end
@pretty = false
@parser.on("-p", "--pretty", "Use human readable JSON ouptut") do
@pretty = true
end
end
|
Instance Method Details
#parse_args(argv) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/perfmonger/command/play.rb', line 31
def parse_args(argv)
@parser.parse!(argv)
if argv.size == 0
puts("ERROR: PerfMonger log file is required")
puts(@parser.help)
exit(false)
end
@logfile = argv.shift
if ! File.exists?(@logfile)
puts("ERROR: No such file: #{@logfile}")
puts(@parser.help)
exit(false)
end
end
|
#run(argv) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/perfmonger/command/play.rb', line 48
def run(argv)
parse_args(argv)
@player_bin = ::PerfMonger::Command::CoreFinder.player()
if ! @player_bin
puts("[ERROR] no executable binary found.")
exit(false)
end
cmd = [@player_bin]
if @color
cmd << "-color"
end
if @pretty
cmd << "-pretty"
end
cmd << @logfile
Process.exec(*cmd)
end
|