Permalink
Browse files

Added --sandbox option to script/console that'll roll back all change…

…s made to the database when you quit #672 [bitsweat]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@700 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 3fad0cd commit b008b6f1946bdf6c922f62f9fd587fa74ad6af2a @dhh dhh committed Feb 19, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Added --sandbox option to script/console that'll roll back all changes made to the database when you quit #672 [bitsweat]
+
* Added 'recent' as a rake target that'll run tests for files that changed in the last 10 minutes #612 [bitsweat]
* Changed script/console to default to development environment and drop --no-inspect #650 [bitsweat]
View
@@ -1,5 +1,22 @@
#!/usr/local/bin/ruby
-ENV['RAILS_ENV'] = ARGV[0] || 'development'
-puts "Loading environment: #{ENV['RAILS_ENV']}"
irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
-exec "#{irb} -r config/environment.rb -r irb/completion"
+
+require 'optparse'
+options = {}
+OptionParser.new do |opt|
+ opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| }
+ opt.parse!(ARGV)
+end
+
+libs = " -r #{File.dirname(__FILE__)}/../config/environment"
+libs << " -r #{File.dirname(__FILE__)}/console_sandbox" if options[:sandbox]
+libs << " -r irb/completion"
+
+ENV['RAILS_ENV'] = ARGV.first || 'development'
+if options[:sandbox]
+ puts "Loading #{ENV['RAILS_ENV']} environment in sandbox."
+ puts "Any modifications you make will be rolled back on exit."
+else
+ puts "Loading #{ENV['RAILS_ENV']} environment."
+end
+exec "#{irb} #{libs}"
@@ -47,7 +47,7 @@ def manifest
m.file "environments/test.rb", "config/environments/test.rb"
# Scripts
- %w(console destroy generate server).each do |file|
+ %w(console console_sandbox.rb destroy generate server).each do |file|
m.file "bin/#{file}", "script/#{file}", script_options
end
if options[:gem]

0 comments on commit b008b6f

Please sign in to comment.