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/memory_profiler/cli.rb', line 17
def run(argv)
options = {}
parser = option_parser(options)
parser.parse!(argv)
options = DEFAULTS.merge(options)
unless (script = argv.shift)
puts parser
puts ""
puts "#{VERSION_INFO} | ERROR: Must specify a script to run"
return STATUS_ERROR
end
if script == "run"
profile_command(options, argv)
else
begin
MemoryProfiler.start(options)
load(script)
ensure
report = MemoryProfiler.stop
report.pretty_print(**options)
end
STATUS_SUCCESS
end
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e
puts parser
puts e.message
STATUS_ERROR
end
|