From 4351419ba510be02b99215028807e8341c26428c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 16 Jun 2005 05:50:24 +0000 Subject: Added -e/--environment option to script/runner #1408 [fbeausoleil@ftml.net] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1430 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/CHANGELOG | 2 ++ railties/bin/runner | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 8f6de2d135..bd621c9032 100644 --- a/railties/CHANGELOG +++ b/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] diff --git a/railties/bin/runner b/railties/bin/runner index acb18f0098..c319bfe658 100644 --- a/railties/bin/runner +++ b/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' -- cgit v1.2.3