diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-29 07:45:08 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-29 07:45:08 +0000 |
commit | 3c877ecd8a4ee2a0b27f30ff557b400d567540a6 (patch) | |
tree | 980c9b2bff6361a3238cf1aa88a1011defbf982a /railties/lib/commands | |
parent | 643d17ce9e6937425a9e39e6ef6fae07efd15b8a (diff) | |
download | rails-3c877ecd8a4ee2a0b27f30ff557b400d567540a6.tar.gz rails-3c877ecd8a4ee2a0b27f30ff557b400d567540a6.tar.bz2 rails-3c877ecd8a4ee2a0b27f30ff557b400d567540a6.zip |
Use the first unparsed argument as the code or file to run. Closes #6286.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5203 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/commands')
-rw-r--r-- | railties/lib/commands/runner.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/railties/lib/commands/runner.rb b/railties/lib/commands/runner.rb index b2efba4dca..62db8b75e1 100644 --- a/railties/lib/commands/runner.rb +++ b/railties/lib/commands/runner.rb @@ -1,6 +1,7 @@ require 'optparse' options = { :environment => (ENV['RAILS_ENV'] || "development").dup } +code_or_file = nil ARGV.clone.options do |opts| script_name = File.basename($0) @@ -27,19 +28,21 @@ ARGV.clone.options do |opts| opts.separator "-------------------------------------------------------------" end - opts.parse! rescue retry + opts.order! { |o| code_or_file ||= o } rescue retry end +ARGV.delete(code_or_file) + ENV["RAILS_ENV"] = options[:environment] RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) require RAILS_ROOT + '/config/environment' -if ARGV.empty? +if code_or_file.nil? $stderr.puts "Run '#{$0} -h' for help." exit 1 -elsif File.exists?(ARGV.first) - eval(File.read(ARGV.shift)) +elsif File.exists?(code_or_file) + eval(File.read(code_or_file)) else - eval(ARGV.first) + eval(code_or_file) end |