Class: DroppableTable::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/droppable_table/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/droppable_table/cli.rb', line 50

def self.exit_on_failure?
  true
end

Instance Method Details

#analyzeObject



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
  # Load configuration
  config = Config.new(options[:config])

  # Run analysis
  analyzer = Analyzer.new(config)
  analyzer.analyze

  # Generate report
  if options[:json]
    puts JSON.pretty_generate(analyzer.report(format: :json))
  else
    puts analyzer.report(format: :text)
  end

  # Handle strict mode
  handle_strict_mode(analyzer, config) if options[:strict] && config.strict_mode_enabled?

  # Exit with appropriate code
  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

#versionObject



45
46
47
# File 'lib/droppable_table/cli.rb', line 45

def version
  puts "DroppableTable #{DroppableTable::VERSION}"
end