Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Removed all the default commands in script/* and replaced them with s…
…cript/rails and a rails command that'll act the same when run from within the app [DHH]
- Loading branch information
Showing
15 changed files
with
118 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
railties/lib/generators/rails/app/templates/script/console.tt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
railties/lib/generators/rails/app/templates/script/dbconsole.tt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
railties/lib/generators/rails/app/templates/script/performance/benchmarker
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
railties/lib/generators/rails/app/templates/script/performance/profiler
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, this is cool.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No aliases anymore =).
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweetness. no more fat fingering the slashes.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so nice.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool, but merb's way (merb, merb-gen) is better imho.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you type "rails generate",
then shell finds "rails" command somewhere in "usr/local/bin"
then it runs it just to ask ruby to search actual rails executable buried somewhere in your gems
just to find real rails in your script/ directory
and execute it, and once again
nice, two unnecessary steps
gonna buy faster laptop
or write witty alias for rails
P.S. zsh allows me to type
s/g TAB to complete script/generate, so no relaxation for fingers either
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codesnik, I recommend you do not look at how Ruby code is turned into Assembler. The inefficiencies that the Ruby community at large go through to present a nicer human environment is probably disgusting to most if you look under the covers. Don't look inside inside the chocolate factory!
Also, you can do "rails g" for generate. All the major commands have shortcuts. See "rails --help" for an index of them all.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, there's a chocolate factory? Sounds like _why's secret hiding place.
+1 Nice commit.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When trying to create a new app -
rails/railties/bin/rails: line 1: syntax error near unexpected token
Dir.getwd' rails/railties/bin/rails: line 1:
if File.exists?(Dir.getwd + '/script/rails')'d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really wishing you could delete comments right about now...
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'm a little grouchy here. still, i'd like to hear what jruby guys feel about extra "exec".
but of course they can use script/rails
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you guys should modify the default index page though, there is no script/generate any more. :)
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@changwang thanks, will be fixed shortly
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for what I always have been waited for
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay ! :)
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea; script/* was always something that felt clunky. I'm alright with the extra "exec" ;-)
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix. Its definitely better than the actual way.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, i'm using 'db' shortcut for script/dbconsole :D
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See http://github.com/rails/rails/commit/f390eade5fd70615ba2ee8e089821bcf2d5f7b17 -- we added rails db as a shortcut for dbconsole.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little bit confused by the new way to go. I created a brand new app with ruby rails my_app --dev, rails being an alias to my railties/bin/rails. Went fine, bundle's ok. But now I want to run the server, so I guess I must do ruby rails s, but I only get a load of code being prompted. Ctrl-Cing and checking for the error backtrace, I read:
WARNING: Invalid .gemspec format in '/home/jd/.gem/ruby/1.9.1/specifications/mail-2.1.2.gemspec'
WARNING: #<NoMethodError: undefined method `>' for nil:NilClass>
-*- encoding: u^C/opt/ruby1.9/lib/ruby1.9/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/user_interaction.rb:240:in `write': Interrupt
What did I do wrong? Brand new install of Ruby1.9 from source, Rails edge fetched from git following RailsBlog wycats instructions.
Thx.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get this:
WARNING: Invalid .gemspec format in '/var/lib/gems/1.9.0/specifications/memcache-client-1.7.7.gemspec'
/home/grigio/Documenti/rails/railties/lib/rails.rb:25:in
<top (required)>': undefined method
default_external=' for Encoding:Class (NoMethodError)d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG! internal:gem_prelude:114:in
push_gem_version_on_load_path': undefined method
<=>' for nil:NilClass (NoMethodError)from internal:gem_prelude:8:in `gem'
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meanwhile, for zsh (bash too?) users out there
http://gist.github.com/298942
so it would work even while rails3 is in beta. and maybe afterwards.
d236827
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codesnik, why not just run script/rails directly if you are worried about the additional exec?