mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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]
This commit is contained in:
parent
144f41ed9b
commit
d236827881
15 changed files with 118 additions and 53 deletions
|
@ -1,5 +1,11 @@
|
||||||
*Edge*
|
*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]
|
* 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]
|
* Set config.time_zone to UTC by default [DHH]
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
begin
|
if File.exists?(Dir.getwd + '/script/rails')
|
||||||
require 'rails/ruby_version_check'
|
exec(Dir.getwd + '/script/rails', *ARGV)
|
||||||
rescue LoadError
|
else
|
||||||
# If people are not using gems, the load path must still
|
begin
|
||||||
# be correct.
|
require 'rails/ruby_version_check'
|
||||||
# TODO: Remove the begin / rescue block somehow
|
rescue LoadError
|
||||||
$:.unshift File.expand_path('../../lib', __FILE__)
|
# If people are not using gems, the load path must still
|
||||||
$:.unshift File.expand_path('../../../activesupport/lib', __FILE__)
|
# be correct.
|
||||||
$:.unshift File.expand_path('../../../actionpack/lib', __FILE__)
|
# TODO: Remove the begin / rescue block somehow
|
||||||
require 'rails/ruby_version_check'
|
$:.unshift File.expand_path('../../lib', __FILE__)
|
||||||
end
|
$:.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'
|
require 'rails/version'
|
||||||
if %w(--version -v).include? ARGV.first
|
if %w(--version -v).include? ARGV.first
|
||||||
puts "Rails #{Rails::VERSION::STRING}"
|
puts "Rails #{Rails::VERSION::STRING}"
|
||||||
exit(0)
|
exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
ARGV << "--help" if ARGV.empty?
|
ARGV << "--help" if ARGV.empty?
|
||||||
|
|
||||||
|
require 'rails/generators'
|
||||||
|
require 'generators/rails/app/app_generator'
|
||||||
|
|
||||||
require 'rails/generators'
|
Rails::Generators::AppGenerator.start
|
||||||
require 'generators/rails/app/app_generator'
|
end
|
||||||
|
|
||||||
Rails::Generators::AppGenerator.start
|
|
|
@ -1,3 +0,0 @@
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
|
||||||
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
|
|
||||||
require 'rails/commands/about'
|
|
|
@ -1,5 +0,0 @@
|
||||||
require File.expand_path('../../config/boot', __FILE__)
|
|
||||||
require 'rails/commands/console'
|
|
||||||
require File.expand_path('../../config/application', __FILE__)
|
|
||||||
|
|
||||||
Rails::Console.start(Rails::Application)
|
|
|
@ -1,5 +0,0 @@
|
||||||
require File.expand_path('../../config/boot', __FILE__)
|
|
||||||
require 'rails/commands/dbconsole'
|
|
||||||
require File.expand_path('../../config/application', __FILE__)
|
|
||||||
|
|
||||||
Rails::DBConsole.start(Rails::Application)
|
|
|
@ -1,2 +0,0 @@
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
|
||||||
require 'rails/commands/destroy'
|
|
|
@ -1,2 +0,0 @@
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
|
||||||
require 'rails/commands/generate'
|
|
|
@ -1,2 +0,0 @@
|
||||||
require File.expand_path('../../../config/environment', __FILE__)
|
|
||||||
require 'rails/commands/performance/benchmarker'
|
|
|
@ -1,2 +0,0 @@
|
||||||
require File.expand_path('../../../config/environment', __FILE__)
|
|
||||||
require 'rails/commands/performance/profiler'
|
|
|
@ -1,2 +0,0 @@
|
||||||
require File.expand_path('../../config/application', __FILE__)
|
|
||||||
require 'rails/commands/plugin'
|
|
6
railties/lib/generators/rails/app/templates/script/rails
Normal file
6
railties/lib/generators/rails/app/templates/script/rails
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
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'
|
|
@ -1,3 +0,0 @@
|
||||||
require File.expand_path('../../config/boot', __FILE__)
|
|
||||||
require 'rails/commands/runner'
|
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
|
|
@ -1,5 +0,0 @@
|
||||||
require File.expand_path('../../config/boot', __FILE__)
|
|
||||||
require 'rails/commands/server'
|
|
||||||
|
|
||||||
Dir.chdir(File.expand_path('../..', __FILE__))
|
|
||||||
Rails::Server.start
|
|
12
railties/lib/rails/commands/application.rb
Normal file
12
railties/lib/rails/commands/application.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
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
|
69
railties/lib/rails/commands/rails.rb
Normal file
69
railties/lib/rails/commands/rails.rb
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
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
|
Loading…
Reference in a new issue