Class: Rsodx::Cli::Commands::Console

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/rsodx/cli/commands/console.rb

Instance Method Summary collapse

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rsodx/cli/commands/console.rb', line 9

def call(*)
  project_root = Rsodx.project_root
  environment_path = File.join(project_root, "config", "environment.rb")

  unless File.exist?(environment_path)
    abort "❌ Could not find config/environment.rb in #{project_root}"
  end

  require environment_path

  TOPLEVEL_BINDING.eval('def reload!; Rsodx.reload!; end')

  puts Rsodx::
  puts "🔬 Welcome to Rsodx console (#{ENV['RACK_ENV'] || 'development'})"
  puts "Tip: access Rsodx modules, models, services, etc."

  ARGV.clear
  IRB.start
rescue LoadError => e
  abort "❌ Failed to load: #{e.message}"
rescue StandardError => e
  abort "❌ An error occurred: #{e.message}"
end