def help(shell, meth=nil, options={})
meth, options = nil, meth if meth.is_a?(Hash)
if meth
task = all_tasks[meth]
raise UndefinedTaskError, "task '#{meth}' could not be found in namespace '#{self.namespace}'" unless task
shell.say "Usage:"
shell.say " #{banner(task, options[:namespace], false)}"
shell.say
class_options_help(shell, "Class", :Method => task.options.map { |_, o| o })
shell.say task.description
else
list = (options[:short] ? tasks : all_tasks).map do |_, task|
item = [ banner(task, options[:namespace]) ]
item << "# #{task.short_description}" if task.short_description
item << " "
end
options[:ident] ||= 2
if options[:short]
shell.print_list(list, :ident => options[:ident])
else
shell.say "Tasks:"
shell.print_list(list, :ident => options[:ident])
end
Thor::Util.thor_classes_in(self).each do |subclass|
namespace = options[:namespace] == true || subclass.namespace.gsub(/^#{self.namespace}:/, '')
subclass.help(shell, options.merge(:short => true, :namespace => namespace))
end
class_options_help(shell, "Class") unless options[:short]
end
end