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
51
52
53
54
|
# File 'lib/necropsy/cli.rb', line 18
def run(argv)
command = argv.first&.start_with?('-') ? 'analyze' : argv.shift || 'analyze'
options = default_options
parser = build_parser(options)
parser.parse!(argv)
apply_config_defaults(options)
case command
when 'analyze'
report = analyze(options)
puts Reporter.new(report).render(format: options[:format], min_confidence: options[:min_confidence])
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)
else
warn "Unknown command: #{command}"
warn parser
2
end
rescue OptionParser::ParseError, Error => e
warn e.message
2
end
|