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
|
# File 'lib/droppable_table/cli.rb', line 14
def analyze
config = Config.new(options[:config])
analyzer = Analyzer.new(config)
analyzer.analyze
if options[:json]
puts JSON.pretty_generate(analyzer.report(format: :json))
else
puts analyzer.report(format: :text)
end
handle_strict_mode(analyzer, config) if options[:strict] && config.strict_mode_enabled?
exit(analyzer.droppable_tables.empty? ? 0 : 1) if options[:strict]
rescue RailsNotFoundError => e
error_exit("Rails application not found: #{e.message}")
rescue MigrationPendingError => e
error_exit("Migration pending: #{e.message}")
rescue SchemaNotFoundError => e
error_exit("Schema not found: #{e.message}")
rescue StandardError => e
error_exit("Error: #{e.message}\n#{e.backtrace.first(5).join("\n")}")
end
|