blob: 9f105d2e196cadd79fee5df3a1c7d78850795181 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
require File.dirname(__FILE__) + '/../lib/ruby_version_check'
Signal.trap("INT") { puts; exit }
require File.dirname(__FILE__) + '/../lib/rails/version'
if %w(--version -v).include? ARGV.first
puts "Rails #{Rails::VERSION::STRING}"
exit(0)
end
require File.dirname(__FILE__) + '/../lib/generators'
if ARGV.size == 0
rails = Rails::Generators.builtin.map do |group, name|
name if group == "rails"
end
rails.compact!
rails.sort!
others = Rails::Generators.builtin.map do |group, name|
"#{group}:#{name}" unless rails.include?(name)
end.compact
others.sort!
puts "Please select a generator."
puts "Builtin: #{rails.join(', ')}."
puts "Others: #{others.join(', ')}." unless others.empty?
exit
end
Rails::Generators.builtin.each do |group, name|
require "generators/#{group}/#{name}/#{name}_generator"
end
name = ARGV.shift
if klass = Rails::Generators.find_by_namespace(name, "rails")
ARGV << "--help" if klass.arguments.any? { |a| a.required? } && ARGV.empty?
klass.start
else
puts "Could not find generator #{name}."
end
|