diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-07 11:49:38 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-07 11:49:38 +0000 |
commit | 2594581e9f5594b32918326be895b4d443ab3e9c (patch) | |
tree | 051f52e4619b70f4757dbabf362d51a7d5f5fde9 /railties/generators/generate.rb | |
parent | 3ee4357b8643c611bbe9eb3a7ce820a5e32cddaa (diff) | |
download | rails-2594581e9f5594b32918326be895b4d443ab3e9c.tar.gz rails-2594581e9f5594b32918326be895b4d443ab3e9c.tar.bz2 rails-2594581e9f5594b32918326be895b4d443ab3e9c.zip |
Added a better generator for scaffolding that actually creates the code, so it can be edited bit by bit. See "script/generate scaffold" [bitsweat]. Added a whole new approach to generators that used the shared "script/generate" command. Run with no-args to see help [bitsweat].
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@63 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/generators/generate.rb')
-rwxr-xr-x | railties/generators/generate.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/railties/generators/generate.rb b/railties/generators/generate.rb new file mode 100755 index 0000000000..8f2f1497d6 --- /dev/null +++ b/railties/generators/generate.rb @@ -0,0 +1,41 @@ +#!/usr/local/bin/ruby +require File.dirname(__FILE__) + '/../config/environment' +require 'rails_generator' + +unless ARGV.empty? + begin + name = ARGV.shift + Rails::Generator.instance(name, ARGV).generate + rescue Rails::Generator::UsageError => e + puts e.message + end +else + builtin_generators = Rails::Generator.builtin_generators.join(', ') + contrib_generators = Rails::Generator.contrib_generators.join(', ') + + $stderr.puts <<end_usage + #{$0} generator [args] + + Rails comes with #{builtin_generators} generators. + #{$0} controller Login login logout + #{$0} model Account + #{$0} mailer AccountMailer + #{$0} scaffold Account action another_action + +end_usage + + unless contrib_generators.empty? + $stderr.puts " Installed generators (in #{RAILS_ROOT}/generators):" + $stderr.puts " #{contrib_generators}" + $stderr.puts + end + + $stderr.puts <<end_usage + More generators are available at http://rubyonrails.org + 1. Download, for example, auth_controller.zip + 2. Unzip to directory #{RAILS_ROOT}/generators/auth_controller + 3. Generate without args for usage information + #{$0} auth_controller +end_usage + exit 0 +end |