function drush_do_command_redispatch

8.0.x drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL, $user_interactive = FALSE, $aditional_options = array())
6.x drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL)
7.x drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL, $user_interactive = FALSE, $aditional_options = array())
3.x drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL)
4.x drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL)
5.x drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL)
master drush.inc drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL, $user_interactive = FALSE, $aditional_options = array())

Redispatch the specified command using the same options that were passed to this invocation of drush.

Related topics

1 call to drush_do_command_redispatch()
drush_preflight_command_dispatch in includes/preflight.inc
Handle any command preprocessing that may need to be done, including potentially redispatching the command immediately (e.g. for remote commands).

File

includes/drush.inc, line 1166
The drush API implementation and helpers.

Code

function drush_do_command_redispatch($command, $args = array(), $remote_host = NULL, $remote_user = NULL, $drush_path = NULL, $user_interactive = FALSE, $aditional_options = array()) {
  $additional_global_options = array();
  $command_options = drush_redispatch_get_options();
  $command_options = $aditional_options + $command_options;
  if (is_array($command)) {
    $command_name = $command['command'];
    // If we are executing a remote command that uses strict option handling,
    // then mark all of the options in the alias context as global, so that they
    // will appear before the command name.
    if (!empty($command['strict-option-handling'])) {
      foreach (drush_get_context('alias') as $alias_key => $alias_value) {
        if (array_key_exists($alias_key, $command_options) && !array_key_exists($alias_key, $command['options'])) {
          $additional_global_options[$alias_key] = $alias_value;
        }
      }
    }
  }
  else {
    $command_name = $command;
  }
  // If the path to drush was supplied, then use it to invoke the new command.
  if ($drush_path == NULL) {
    $drush_path = drush_get_option('drush-script');
    if (!isset($drush_path)) {
      $drush_folder = drush_get_option('drush');
      if (isset($drush)) {
        $drush_path = $drush_folder . '/drush';
      }
    }
  }
  $backend_options = array(
    'drush-script' => $drush_path,
    'remote-host' => $remote_host,
    'remote-user' => $remote_user,
    'integrate' => TRUE,
    'additional-global-options' => $additional_global_options,
  );
  // Set the tty if requested, if the command necessitates it,
  // or if the user explicitly asks for interactive mode, but
  // not if interactive mode is forced.  tty implies interactive
  if (drush_get_option('tty') || $user_interactive || !empty($command['remote-tty'])) {
    $backend_options['#tty'] = TRUE;
    $backend_options['interactive'] = TRUE;
  }
  elseif (drush_get_option('interactive')) {
    $backend_options['interactive'] = TRUE;
  }

  // Run the command in a new process.
  drush_log(dt('Begin redispatch via drush_invoke_process().'));
  $values = drush_invoke_process('@self', $command_name, $args, $command_options, $backend_options);
  drush_log(dt('End redispatch via drush_invoke_process().'));

  return $values;
}