提交 7466d6a9 编写于 作者: R Richard Schneeman

Merge pull request #15293 from schneems/schneems/generator-output-in-error

print generators on failed generate
...@@ -156,7 +156,8 @@ def self.invoke(namespace, args=ARGV, config={}) ...@@ -156,7 +156,8 @@ def self.invoke(namespace, args=ARGV, config={})
args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? } args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? }
klass.start(args, config) klass.start(args, config)
else else
puts "Could not find generator #{namespace}." puts "Could not find generator #{namespace.inspect}."
print_generators
end end
end end
...@@ -199,17 +200,6 @@ def hide_namespaces(*namespaces) ...@@ -199,17 +200,6 @@ def hide_namespaces(*namespaces)
# Show help message with available generators. # Show help message with available generators.
def self.help(command = 'generate') def self.help(command = 'generate')
lookup!
namespaces = subclasses.map{ |k| k.namespace }
namespaces.sort!
groups = Hash.new { |h,k| h[k] = [] }
namespaces.each do |namespace|
base = namespace.split(':').first
groups[base] << namespace
end
puts "Usage: rails #{command} GENERATOR [args] [options]" puts "Usage: rails #{command} GENERATOR [args] [options]"
puts puts
puts "General options:" puts "General options:"
...@@ -222,6 +212,20 @@ def self.help(command = 'generate') ...@@ -222,6 +212,20 @@ def self.help(command = 'generate')
puts "Please choose a generator below." puts "Please choose a generator below."
puts puts
print_generators
end
def self.print_generators
lookup!
namespaces = subclasses.map{ |k| k.namespace }
namespaces.sort!
groups = Hash.new { |h,k| h[k] = [] }
namespaces.each do |namespace|
base = namespace.split(':').first
groups[base] << namespace
end
# Print Rails defaults first. # Print Rails defaults first.
rails = groups.delete("rails") rails = groups.delete("rails")
rails.map! { |n| n.sub(/^rails:/, '') } rails.map! { |n| n.sub(/^rails:/, '') }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册