2005-06-16 01:50:24 -04:00
|
|
|
require 'optparse'
|
|
|
|
|
2005-10-13 22:51:33 -04:00
|
|
|
options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
|
2005-06-16 01:50:24 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2005-10-12 08:44:03 -04:00
|
|
|
ENV["RAILS_ENV"] = options[:environment]
|
|
|
|
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
|
2005-06-16 01:50:24 -04:00
|
|
|
|
2005-09-29 08:18:51 -04:00
|
|
|
require RAILS_ROOT + '/config/environment'
|
2005-10-12 08:41:23 -04:00
|
|
|
eval(ARGV.first)
|