Skip to content
Browse files

Added -e/--environment option to script/runner #1408 [fbeausoleil@ftm…

…l.net]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1430 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6915627 commit 4351419ba510be02b99215028807e8341c26428c @dhh dhh committed Jun 16, 2005
Showing with 26 additions and 0 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +24 −0 railties/bin/runner
View
2 railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added -e/--environment option to script/runner #1408 [fbeausoleil@ftml.net]
+
* Modernize the scaffold generator to use the simplified render and test methods and to change style from @params["id"] to params[:id]. #1367
* Added graceful exit from pressing CTRL-C during the run of the rails command #1150 [Caleb Tennis]
View
24 railties/bin/runner
@@ -1,3 +1,27 @@
+require 'optparse'
+
+options = { :environment => "development" }
+
+ARGV.options do |opts|
+ script_name = File.basename($0)
+ opts.banner = "Usage: runner 'puts Person.find(1).name' [options]"
+
+ opts.separator ""
+
+ opts.on("-e", "--environment=name", String,
+ "Specifies the environment for the runner to operate under (test/development/production).",
+ "Default: development") { |options[:environment]| }
+
+ opts.separator ""
+
+ opts.on("-h", "--help",
+ "Show this help message.") { puts opts; exit }
+
+ opts.parse!
+end
+
+ENV["RAILS_ENV"] = options[:environment]
+
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + '/../config/environment'

0 comments on commit 4351419

Please sign in to comment.
Something went wrong with that request. Please try again.