module Thor::Invocation

def _retrieve_class_and_command(name, sent_command = nil) #:nodoc:

:nodoc:
prepare_for_invocation in the current class.
use the given name and return self as class. Otherwise, call
If the name is nil or the given name is a command in the current class,
This method simply retrieves the class and command to be invoked.
def _retrieve_class_and_command(name, sent_command = nil) #:nodoc:
  case
  when name.nil?
    [self.class, nil]
  when self.class.all_commands[name.to_s]
    [self.class, name.to_s]
  else
    klass, command = self.class.prepare_for_invocation(nil, name)
    [klass, command || sent_command]
  end
end