? drush_pm
? drush_pm_cvs
? drush_pm_svn
? drush_pm_wget
? drush_simpletest
? drush_sql
? drush_tools
? example.drushrc.phpe
? services
? commands/pm/handler
? includes/table.inc
Index: drush.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/drush.php,v
retrieving revision 1.78
diff -u -p -r1.78 drush.php
--- drush.php	6 Dec 2009 12:53:38 -0000	1.78
+++ drush.php	15 Dec 2009 21:51:59 -0000
@@ -143,43 +143,73 @@ function drush_remote_command() {
 
     $args = drush_get_arguments();
     $command = array_shift($args);
-    $data = drush_get_context('options');
-
-    // Most command options are forwarded on to the remote
-    // server; however, we will clear certain flags such as
-    // -v, -d and -i from the 'options' context (defaults, and
-    // options passed in on the command line).
-    foreach (array('v', 'd', 'i') as $key) {
-      unset($data[$key]);
-    }
+    $remote_user = drush_get_option('remote-user');
 
-    // After we clear out the flags we do not want from the
-    // 'options' context, we will add in the 'root' and 'uri'
-    // options from the 'alias' context.
-    foreach (array('root', 'r', 'uri', 'l') as $key) {
-      $value = drush_get_option($key, null, 'alias');
-      if (isset($value)) {
-        $data[$key] = $value;
+    _drush_do_command_redispatch($command, $args, $remote_host, $remote_user);
+    return TRUE;
+  }
+  // If the --site-list flag is set, then we will execute the specified
+  // command once for every site listed in the site list.
+  $site_list = drush_get_option('site-list');
+  if (isset($site_list)) {
+    if (!is_array($site_list)) {
+      $site_list = explode(',', $site_list);
+    }
+    $args = drush_get_arguments();
+    foreach ($site_list as $site_spec) {
+      $site_record = _drush_sitealias_get_record($site_spec);
+      if (!empty($site_record)) {
+        // Pass only the root and uri parameters from the site alias;
+        // put them in the 'options' context where they are sure to
+        // be picked up by the command redispatch helper.  Also,
+        // this insures that "drush --root=/some/other/root site1.com,site2.com,sitealias status"
+        // will work, even if 'sitealias' has a different root than
+        // site1 and site2.
+        drush_set_option('root', $site_record['root'], 'options');
+        drush_set_option('uri', $site_record['uri'], 'options');
+        _drush_do_command_redispatch($site_spec, $args, $site_record['remote-host'], $site_record['remote-user']);
       }
     }
+    return TRUE;
+  }
+  return FALSE;
+}
+
+function _drush_do_command_redispatch($command, $args, $remote_host = NULL, $remote_user = NULL) {
+  $data = _drush_redispatch_get_options();
 
-    // Finally, we call backend invoke with the
-    // specified remote host, remote user and drush path.
-    $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';
+  // If the path to drush was supplied, then pass it to backend invoke.
+  // (Perhaps this should be added to the default handling of backend invoke.)
+  $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';
+    }
+  }
+  // Call through to backend invoke.
+  drush_log(dt('Begin redispatch via backend invoke'));
+  $values = drush_backend_invoke_args($command, $args, $data, 'GET', TRUE, $drush_path, $remote_host, $remote_user);
+  drush_log(dt('Backend invoke is complete'));
+}
+
+function _drush_redispatch_get_options() {
+  // Start off by taking everything from the command line ('options' context)
+  $options = drush_get_context('options');
+  // 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;
       }
     }
-    $remote_user = drush_get_option('remote-user');
-    drush_log(dt('Begin drush_backend_invoke'));
-    $values = drush_backend_invoke_args($command, $args, $data, 'GET', TRUE, $drush_path, $remote_host, $remote_user);
-    drush_log(dt('drush_backend_invoke is complete'));
-
-    return TRUE;
   }
-  return FALSE;
+  return $options;
 }
 
 /**
Index: includes/sitealias.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/sitealias.inc,v
retrieving revision 1.8
diff -u -p -r1.8 sitealias.inc
--- includes/sitealias.inc	10 Dec 2009 20:21:46 -0000	1.8
+++ includes/sitealias.inc	15 Dec 2009 21:51:59 -0000
@@ -61,6 +61,19 @@ function drush_sitealias_check_arg() {
  *   An alias record.
  */
 function drush_sitealias_get_record($alias, $db_settings_needed = false) {
+  // Check to see if the alias contains commas.  If it does, then
+  // we will go ahead and make a site list record
+  $alias_record = array();
+  if (strpos($alias, ',') !== false) {
+    $alias_record['site-list'] = explode(',', $alias);
+  }
+  else {
+    $alias_record = _drush_sitealias_get_record($alias, $db_settings_needed);
+  }
+  return $alias_record;
+}
+
+function _drush_sitealias_get_record($alias, $db_settings_needed = false) {
   // Sometimes getting an alias record involves loading settings.php or calling
   // backend invoke.  We'll cache all alias records fetched by this routine to
   // insure that we never have to do anything like that twice.
@@ -438,11 +451,14 @@ function _drush_sitealias_set_context_by
  *   'destination-databases'.
  */
 function drush_sitealias_set_alias_context($site_alias_settings, $prefix) {
+  // backend invoke needs 'root' and 'uri' on the command line, so we will
+  // handle these two specially
+  $special = empty($prefix) ? array('root', 'uri') : array();
   // Transfer all non-array options from the site alias to the drush options
   // in the 'alias' context.
   foreach ($site_alias_settings as $key => $value) {
-    if (!is_array($value) || ($key == "databases")) {
-      drush_set_option($prefix . $key, $value, 'alias');
+    if (!is_array($value) || ($key == "databases") || ($key == "site-list")) {
+      drush_set_option($prefix . $key, $value, in_array($key, $special) ? 'options' : 'alias');
     }
   }
   // Transfer selected path aliases to the drush options.
