1
0
Fork 0
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:
David Heinemeier Hansson 2010-02-02 15:50:56 -08:00
parent 144f41ed9b
commit d236827881
15 changed files with 118 additions and 53 deletions

View file

@ -1,5 +1,11 @@
*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]

View file

@ -1,27 +1,30 @@
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

View file

@ -1,3 +0,0 @@
require File.expand_path('../../config/environment', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'rails/commands/about'

View file

@ -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)

View file

@ -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)

View file

@ -1,2 +0,0 @@
require File.expand_path('../../config/environment', __FILE__)
require 'rails/commands/destroy'

View file

@ -1,2 +0,0 @@
require File.expand_path('../../config/environment', __FILE__)
require 'rails/commands/generate'

View file

@ -1,2 +0,0 @@
require File.expand_path('../../../config/environment', __FILE__)
require 'rails/commands/performance/benchmarker'

View file

@ -1,2 +0,0 @@
require File.expand_path('../../../config/environment', __FILE__)
require 'rails/commands/performance/profiler'

View file

@ -1,2 +0,0 @@
require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/plugin'

View 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'

View file

@ -1,3 +0,0 @@
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/runner'
require File.expand_path('../../config/environment', __FILE__)

View 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

View 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

View 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