class Thor

def dispatch(meth, given_args, given_opts, config) #:nodoc:

:nodoc:
The method responsible for dispatching given the args.
def dispatch(meth, given_args, given_opts, config) #:nodoc:
  meth ||= retrieve_task_name(given_args)
  task = all_tasks[normalize_task_name(meth)]
  if task
    args, opts = Thor::Options.split(given_args)
  else
    args, opts = given_args, nil
    task = Thor::DynamicTask.new(meth)
  end
  opts = given_opts || opts || []
  config.merge!(:current_task => task, :task_options => task.options)
  trailing = args[Range.new(arguments.size, -1)]
  new(args, opts, config).invoke_task(task, trailing || [])
end