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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/necropsy/cli.rb', line 19
def run(argv)
command = argv.first&.start_with?('-') ? 'analyze' : argv.shift || 'analyze'
options = default_options
parser = build_parser(options)
parser.parse!(argv)
if options[:help]
puts parser
return 0
end
if options[:version]
puts Necropsy::VERSION
return 0
end
apply_config_defaults(options)
case command
when 'analyze'
report = analyze(options)
puts Reporter.new(report).render(
format: options[:format],
min_confidence: options[:min_confidence],
include_graph: options[:include_graph]
)
0
when 'baseline'
report = analyze(options)
path = File.expand_path(options[:baseline], options[:root])
Guardrail::Baseline.write(report, path: path)
puts "Wrote #{path}"
0
when 'check'
check(options)
when 'quarantine'
quarantine(options)
when 'bench'
bench(options)
when 'record'
record(options, argv)
when 'coverage'
coverage(options, argv)
when 'why', 'explain'
diagnose(command, options, argv)
else
warn "Unknown command: #{command}"
warn parser
2
end
rescue OptionParser::ParseError, Psych::Exception, Error => e
warn e.message
2
end
|