function drush_redispatch_get_options

8.0.x command.inc drush_redispatch_get_options()
6.x command.inc drush_redispatch_get_options()
7.x command.inc drush_redispatch_get_options()
3.x drush.inc drush_redispatch_get_options()
4.x command.inc drush_redispatch_get_options()
5.x command.inc drush_redispatch_get_options()
master command.inc drush_redispatch_get_options()

Get the options for this command.

This function returns an array that contains all of the options that are appropriate for forwarding along to backend invoke. Pass the result from this function to backend invoke in the $data parameter when doing a redispatch.

Related topics

2 calls to drush_redispatch_get_options()
drush_do_command_redispatch in includes/drush.inc
Redispatch the specified command using the same options that were passed to this invocation of drush.
drush_do_multiple_command in includes/drush.inc
Used by functions that operate on lists of sites, moving information from the source to the destination. Currenlty this includes 'drush rsync' and 'drush sql sync'.

File

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

Code

function drush_redispatch_get_options() {
  // Start off by taking everything from the site alias and command line
  // ('options' context)
  $alias_context = array_diff_key(drush_get_context('alias'), array_flip(drush_sitealias_site_selection_keys()));
  $options = array_merge($alias_context, drush_get_context('options'));
  unset($options['command-specific']);
  unset($options['path-aliases']);
  // If we can parse the current command, then examine all contexts
  // in order for any option that is directly related to the current command
  $command = drush_parse_command();
  if (is_array($command)) {
    foreach ($command['options'] as $key => $value) {
      // Strip leading --
      $key = ltrim($key, '-');
      $value = drush_get_option($key);
      if (isset($value)) {
        $options[$key] = $value;
      }
    }
  }
  // 'php', if needed, will be included in DRUSH_COMMAND.  If DRUSH_COMMAND
  // is not used (e.g. when calling a remote instance of drush), then --php
  // should not be passed along.
  unset($options['php']);

  return $options;
}