1
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
5
options = { :sandbox => false, :irb => irb }
6
OptionParser.new do |opt|
7
opt.banner = "Usage: console [environment] [options]"
8
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
9
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
10
opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
14
libs = " -r irb/completion"
15
libs << %( -r "#{RAILS_ROOT}/config/environment")
16
libs << " -r console_app"
17
libs << " -r console_sandbox" if options[:sandbox]
18
libs << " -r console_with_helpers"
23
libs << " -r ruby-debug"
24
puts "=> Debugger enabled"
26
puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
31
ENV['RAILS_ENV'] = case ARGV.first
32
when "p"; "production"
33
when "d"; "development"
36
ARGV.first || ENV['RAILS_ENV'] || 'development'
40
puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})"
41
puts "Any modifications you make will be rolled back on exit"
43
puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})"
45
exec "#{options[:irb]} #{libs} --simple-prompt"