Removed all the default commands in script/* and replaced them with...

Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]
上级 144f41ed
*Edge*
* Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example:
./script/generate scaffold post title:string can now be called as rails g scaffold post title:string
Run rails --help inside an app for more help.
* Removed config/initializers/new_rails_defaults.rb as all frameworks now follow the settings from it [DHH]
* Set config.time_zone to UTC by default [DHH]
......
begin
require 'rails/ruby_version_check'
rescue LoadError
# If people are not using gems, the load path must still
# be correct.
# TODO: Remove the begin / rescue block somehow
$:.unshift File.expand_path('../../lib', __FILE__)
$:.unshift File.expand_path('../../../activesupport/lib', __FILE__)
$:.unshift File.expand_path('../../../actionpack/lib', __FILE__)
require 'rails/ruby_version_check'
end
if File.exists?(Dir.getwd + '/script/rails')
exec(Dir.getwd + '/script/rails', *ARGV)
else
begin
require 'rails/ruby_version_check'
rescue LoadError
# If people are not using gems, the load path must still
# be correct.
# TODO: Remove the begin / rescue block somehow
$:.unshift File.expand_path('../../lib', __FILE__)
$:.unshift File.expand_path('../../../activesupport/lib', __FILE__)
$:.unshift File.expand_path('../../../actionpack/lib', __FILE__)
require 'rails/ruby_version_check'
end
Signal.trap("INT") { puts; exit }
Signal.trap("INT") { puts; exit }
require 'rails/version'
if %w(--version -v).include? ARGV.first
puts "Rails #{Rails::VERSION::STRING}"
exit(0)
end
require 'rails/version'
if %w(--version -v).include? ARGV.first
puts "Rails #{Rails::VERSION::STRING}"
exit(0)
end
ARGV << "--help" if ARGV.empty?
ARGV << "--help" if ARGV.empty?
require 'rails/generators'
require 'generators/rails/app/app_generator'
require 'rails/generators'
require 'generators/rails/app/app_generator'
Rails::Generators::AppGenerator.start
Rails::Generators::AppGenerator.start
end
\ No newline at end of file
require File.expand_path('../../config/environment', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'rails/commands/about'
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/console'
require File.expand_path('../../config/application', __FILE__)
Rails::Console.start(Rails::Application)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/dbconsole'
require File.expand_path('../../config/application', __FILE__)
Rails::DBConsole.start(Rails::Application)
require File.expand_path('../../config/environment', __FILE__)
require 'rails/commands/destroy'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/commands/generate'
require File.expand_path('../../../config/environment', __FILE__)
require 'rails/commands/performance/benchmarker'
require File.expand_path('../../../config/environment', __FILE__)
require 'rails/commands/performance/profiler'
require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/plugin'
ENV_PATH = File.expand_path('../../config/environment', __FILE__)
BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
APP_PATH = File.expand_path('../../config/application', __FILE__)
require BOOT_PATH
require 'rails/commands/rails'
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/runner'
require File.expand_path('../../config/environment', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/server'
Dir.chdir(File.expand_path('../..', __FILE__))
Rails::Server.start
require 'rails/version'
if %w(--version -v).include? ARGV.first
puts "Rails #{Rails::VERSION::STRING}"
exit(0)
end
ARGV << "--help" if ARGV.empty?
require 'rails/generators'
require 'generators/rails/app/app_generator'
Rails::Generators::AppGenerator.start
\ No newline at end of file
if ARGV.empty?
ARGV << '--help'
end
HELP_TEXT = <<-EOT
usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
In addition to those, there are:
application Generate the Rails application code
dbconsole Start a console for the database specified in config/database.yml
destroy Undo code generated with "generate"
benchmarker See how fast a piece of code runs
profiler Get profile information from a piece of code
plugin Install a plugin
runner Run a piece of code in the application environment
All commands can be run with -h for more information.
EOT
case ARGV.shift
when 'g', 'generate'
require ENV_PATH
require 'rails/commands/generate'
when 'c', 'console'
require BOOT_PATH
require 'rails/commands/console'
require APP_PATH
Rails::Console.start(Rails::Application)
when 's', 'server'
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/server'
Dir.chdir(File.expand_path('../..', __FILE__))
Rails::Server.start
when 'dbconsole'
require BOOT_PATH
require 'rails/commands/dbconsole'
require APP_PATH
Rails::DBConsole.start(Rails::Application)
when 'destroy'
require ENV_PATH
require 'rails/commands/destroy'
when 'benchmarker'
require ENV_PATH
require 'rails/commands/performance/benchmarker'
when 'profiler'
require ENV_PATH
require 'rails/commands/performance/profiler'
when 'plugin'
require APP_PATH
require 'rails/commands/plugin'
when 'runner'
require BOOT_PATH
require 'rails/commands/runner'
require ENV_PATH
when '--help', '-h'
puts HELP_TEXT
else
puts "Error: Command not recognized"
puts HELP_TEXT
end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册