Skip to content

Commit

Permalink
Revert "Speed up script/console by launching IRB directly."
Browse files Browse the repository at this point in the history
[rails#2104 state:open]

This reverts commit 3b169cd.
  • Loading branch information
jeremy committed Mar 2, 2009
1 parent a3ac1e1 commit 04fdb6e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions railties/lib/commands/console.rb
@@ -1,23 +1,26 @@
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'

require 'optparse'

options = { :sandbox => false }
options = { :sandbox => false, :irb => irb }
OptionParser.new do |opt|
opt.banner = "Usage: console [environment] [options]"
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
opt.parse!(ARGV)
end

require 'irb'
require "irb/completion"
require "#{RAILS_ROOT}/config/environment"
require "console_app"
require "console_sandbox" if options[:sandbox]
require "console_with_helpers"
libs = " -r irb/completion"
libs << %( -r "#{RAILS_ROOT}/config/environment")
libs << " -r console_app"
libs << " -r console_sandbox" if options[:sandbox]
libs << " -r console_with_helpers"

if options[:debugger]
begin
require 'ruby-debug'
libs << " -r ruby-debug"
puts "=> Debugger enabled"
rescue Exception
puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
Expand All @@ -39,6 +42,4 @@
else
puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})"
end

ARGV.replace(["--simple-prompt"])
IRB.start
exec "#{options[:irb]} #{libs} --simple-prompt"

0 comments on commit 04fdb6e

Please sign in to comment.