File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
2
2
3
3
require 'optparse'
4
+
4
5
options = { :sandbox => false , :irb => irb }
5
6
OptionParser . new do |opt |
6
7
opt . banner = "Usage: console [environment] [options]"
7
8
opt . on ( '-s' , '--sandbox' , 'Rollback database modifications on exit.' ) { |v | options [ :sandbox ] = v }
8
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 }
9
11
opt . parse! ( ARGV )
10
12
end
11
13
15
17
libs << " -r console_sandbox" if options [ :sandbox ]
16
18
libs << " -r console_with_helpers"
17
19
20
+ if options [ :debugger ]
21
+ begin
22
+ require 'ruby-debug'
23
+ libs << " -r ruby-debug"
24
+ puts "=> Debugger enabled"
25
+ rescue Exception
26
+ puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
27
+ exit
28
+ end
29
+ end
30
+
18
31
ENV [ 'RAILS_ENV' ] = case ARGV . first
19
32
when "p" ; "production"
20
33
when "d" ; "development"
You can’t perform that action at this time.
0 commit comments