blob: 036b1d82757b95be1fa8486dae58bb04d77c9cb4 (
plain) (
tree)
|
|
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
elsif ARGV.size == 1
ARGV << "--help"
end
Rails::Generators.builtin.each do |group, name|
require "generators/#{group}/#{name}/#{name}_generator"
end
name = ARGV.shift
middle = name.sub(':', ':generators:') if name.count(':') == 1
full = "rails:generators:#{name}" if name.count(':') == 0
if full && klass = Thor::Util.find_by_namespace(full)
klass.start
elsif middle && klass = Thor::Util.find_by_namespace(middle)
klass.start
elsif klass = Thor::Util.find_by_namespace(name)
klass.start
else
puts "Could not find generator #{name}."
end
|