Permalink
Browse files

Speed up script/console by launching IRB directly.

[#2104 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 0db6c3f commit 3b169cd693f45911ee71e26708fb9267811c8d83 Charles Nutter committed with jeremy Feb 28, 2009
Showing with 10 additions and 11 deletions.
  1. +10 −11 railties/lib/commands/console.rb
View
21 railties/lib/commands/console.rb
@@ -1,26 +1,23 @@
-irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
-
require 'optparse'
-options = { :sandbox => false, :irb => irb }
+options = { :sandbox => false }
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
-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"
+require 'irb'
+require "irb/completion"
+require "#{RAILS_ROOT}/config/environment"
+require "console_app"
+require "console_sandbox" if options[:sandbox]
+require "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'"
@@ -42,4 +39,6 @@
else
puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})"
end
-exec "#{options[:irb]} #{libs} --simple-prompt"
+
+ARGV.replace(["--simple-prompt"])
+IRB.start

2 comments on commit 3b169cd

@NZKoz
Ruby on Rails member

Awesome, this also stops it from switching interpreters on you when you run some_name_prefix_ruby script/console

@rolfb

Not to happy about this commit:
% script/console production
Loading production environment (Rails 2.3.1)
>> Rails.env
=> “development”

Please sign in to comment.