mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
4b78e5bddb
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2576 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
27 lines
740 B
Ruby
27 lines
740 B
Ruby
require 'optparse'
|
|
|
|
options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
|
|
|
|
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]
|
|
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
|
|
|
|
require RAILS_ROOT + '/config/environment'
|
|
eval(ARGV.first)
|