script/console in damagecontrol-0.5.0 vs script/console in damagecontrol-0.5.0.1391

- old
+ new

@@ -1,30 +1,22 @@ -#!/usr/bin/env ruby +#!c:/ruby/bin/ruby +irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb' -if ARGV[0] - ENV['RAILS_ENV'] = ARGV[0] - puts "Loading environment..." - exec "irb -r config/environment.rb -r irb/completion --noinspect" -else - puts <<-HELP +require 'optparse' +options = {} +OptionParser.new do |opt| + opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| } + opt.parse!(ARGV) +end -NAME - console - interact with the domain model through a environment console (on IRB) +libs = " -r #{File.dirname(__FILE__)}/../config/environment" +libs << " -r #{File.dirname(__FILE__)}/console_sandbox" if options[:sandbox] +libs << " -r irb/completion" -SYNOPSIS - console [environment] - -DESCRIPTION - Starts an environment console using IRB that lets you manipulate and interrogate - the domain model or even trigger controller actions. The database connection and - configuration available to the web application is already setup. - - Tab completion is available to see classes and methods on individual objects. - -EXAMPLE - console production - - This will initialize the production environment (as setup in config/database.yml - and config/environments/production.rb). You would now be ready to start requiring - models using require_dependency. -HELP -end \ No newline at end of file +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}"