Skip to content

Commit

Permalink
Add --debugger option to script/console.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1025 state:committed]
  • Loading branch information
miloops authored and NZKoz committed Sep 11, 2008
1 parent 1ddde91 commit c98cb8f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions railties/lib/commands/console.rb
@@ -1,11 +1,13 @@
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'

require 'optparse'

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

Expand All @@ -15,6 +17,17 @@
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'"
exit
end
end

ENV['RAILS_ENV'] = case ARGV.first
when "p"; "production"
when "d"; "development"
Expand Down

0 comments on commit c98cb8f

Please sign in to comment.