From 0a0ac868453e9d8d9ee1dac6a7eb274772235b05 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 29 Sep 2005 12:18:51 +0000 Subject: Removed all the scripts in script/* and replaced it with one generic portal: script/run git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/commands/runner.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 railties/lib/commands/runner.rb (limited to 'railties/lib/commands/runner.rb') diff --git a/railties/lib/commands/runner.rb b/railties/lib/commands/runner.rb new file mode 100644 index 0000000000..7d1b56e3f9 --- /dev/null +++ b/railties/lib/commands/runner.rb @@ -0,0 +1,26 @@ +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] + +require RAILS_ROOT + '/config/environment' +eval(ARGV.first) \ No newline at end of file -- cgit v1.2.3