? includes/table.inc
Index: example.drushrc.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/example.drushrc.php,v
retrieving revision 1.21
diff -u -p -r1.21 example.drushrc.php
--- example.drushrc.php	30 Dec 2009 21:26:44 -0000	1.21
+++ example.drushrc.php	1 Jan 2010 04:59:24 -0000
@@ -73,6 +73,18 @@ $options['structure-tables'] = array(
 // Use POSIX path separator (':')
 # $options['script-path'] = 'sites/all/scripts:profiles/myprofile/scripts';
 
+/*
+ * Command-specific options
+ *
+ * To define options that are only applicable to certain commands,
+ * make an entry in the 'command-options' structures as shown below.
+ *
+ * Options defined here will be overridden by options of the same
+ * name on the command line.  Unary flags such as "-v" are overridden
+ * via special "--no-xxx" options (e.g. "--no-v").
+ */
+# $options['command-options']['rsync'] = array('show-progress' => TRUE);
+
 /**
  * Variable overrides:
  *
Index: includes/command.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/command.inc,v
retrieving revision 1.48
diff -u -p -r1.48 command.inc
--- includes/command.inc	6 Dec 2009 12:53:38 -0000	1.48
+++ includes/command.inc	1 Jan 2010 04:59:24 -0000
@@ -214,6 +214,7 @@ function drush_parse_command() {
  */
 function drush_invoke($command) {
   drush_command_include($command);
+  drush_command_default_options($command);
   $args = func_get_args();
   array_shift($args);
 
@@ -474,6 +475,36 @@ function drush_command_include($command)
 }
 
 /**
+ * Conditionally include default options based on the command used.
+ */
+function drush_command_default_options($command) {
+  $options_were_set = FALSE;
+  $command_default_options = drush_get_option('command-options', array());
+  if (array_key_exists($command, $command_default_options)) {
+    foreach ($command_default_options[$command] as $key => $value) {
+      // We set command-specific options in their own context
+      // that is higher precidence than the various config file
+      // context, but lower than command-line options.
+      drush_set_default($key, $value, 'command');
+      $options_were_set = TRUE;
+    }
+  }
+  // Take the time here to clear out any options that may
+  // have "--no-xxx" overrides on the command line.
+  $commandline_options = drush_get_context('options');
+  foreach ($commandline_options as $key => $value) {
+    if (substr($key, 0, strlen("no-") ) == "no-") {
+      drush_unset_option(substr($key, strlen("no-")));
+    }
+  }
+  // If we set any options, go back and re-bootstrap any global
+  // options such as -y and -v.
+  if ($options_were_set) {
+    _drush_bootstrap_global_options();
+  }
+}
+
+/**
  * Determine whether a command file implements a hook.
  *
  * @param $module
Index: includes/context.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/context.inc,v
retrieving revision 1.17
diff -u -p -r1.17 context.inc
--- includes/context.inc	28 Dec 2009 22:45:49 -0000	1.17
+++ includes/context.inc	1 Jan 2010 04:59:24 -0000
@@ -43,6 +43,10 @@
  *      process  : Generated in the current process.
  *      options  : Passed as --option=value to the command line.
  *      stdin    : Passed as a JSON encoded string through stdin.
+ *      alias    : Defined in an alias record, and set in the
+ *                 alias context whenever that alias is used.
+ *      command  : Defined in a command-specific option record, and
+ *                 set in the command context whenever that command is used.
  *
  *    Specified by config files :
  *      custom   : Loaded from the config file specified by --config or -c
@@ -61,6 +65,21 @@
 
 
 /**
+ * Return a list of the valid drush context names.
+ *
+ * These context names are carefully ordered from
+ * highest to lowest priority.
+ */
+function _drush_context_names() {
+  static $contexts = array(
+    'process', 'options', 'stdin', 'alias', 'command-specific',
+    'custom', 'site', 'drupal', 'user', 'system',
+    'drush', 'default');
+  
+  return $contexts;
+}
+
+/**
  * Return a list of possible drushrc file locations.
  *
  * @return
@@ -125,22 +144,27 @@ function drush_load_config($context) {
     $options['context-path'][$context] = $config;
     require_once($config);
     
-    // If site aliases are defined in multiple drush configuration files,
-    // the normal mechanism would cause the highest priority 'site-aliases'
-    // array to mask all of the other aliases defined in different contexts.
-    // To allow all of the aliases defined in every context to be used together,
-    // we merge them all into the 'drush' context as they are encountered.
-    if ((isset($options)) && (array_key_exists('site-aliases', $options))) {
-      $cache =& drush_get_context('alias');
-      if (array_key_exists('site-aliases', $cache)) {
-        $cache['site-aliases'] = array_merge($cache['site-aliases'], $options['site-aliases']);
-      }
-      else {
-        $cache['site-aliases'] = $options['site-aliases'];
+    // There are certain options such as 'site-aliases' and 'command-options'
+    // that must be merged together if defined in multiple drush configuration
+    // files.  If we did not do this merge, then the last configuration file
+    // that defined any of these properties would overwrite all of the options
+    // that came before in previously-loaded configuration files.  We place
+    // all of them into the 'default' context so that this does not happen.
+    if (isset($options)) {
+      foreach (array('site-aliases', 'command-options') as $option_name) {
+        if ((isset($options)) && (array_key_exists($option_name, $options))) {
+          $cache =& drush_get_context('default');
+          if (array_key_exists($option_name, $cache)) {
+            $cache[$option_name] = array_merge($cache[$option_name], $options[$option_name]);
+          }
+          else {
+            $cache[$option_name] = $options[$option_name];
+          }
+          unset($options[$option_name]);
+        }
       }
-      unset($options['site-aliases']);
     }
-
+    
     drush_set_context($context, $options);
 
     // Instruct core not to queries since we are not outputting them.
@@ -292,10 +316,7 @@ function drush_get_option($option, $defa
   }
   else {
     // We are not checking a specific context, so check them in a predefined order of precedence.
-    static $contexts = array(
-      'process', 'options', 'stdin', 'alias',
-      'custom', 'site', 'drupal', 'user', 'system',
-      'drush', 'default');
+    $contexts = _drush_context_names();
 
     foreach ($contexts as $context) {
       $value = _drush_get_option($option, drush_get_context($context));
@@ -317,10 +338,7 @@ function drush_get_option($option, $defa
  * Retrieves a collapsed list of all options
  */
 function drush_get_merged_options() {
-  static $contexts = array(
-      'process', 'options', 'stdin', 'alias',
-      'custom', 'site', 'drupal', 'user', 'system',
-      'drush', 'default');
+  $contexts = _drush_context_names();
   $cache = drush_get_context();
   $result = array();
   foreach (array_reverse($contexts) as $context) {
@@ -385,10 +403,19 @@ function drush_set_default($option, $val
  * @param
  *   Context in which to unset the value in.
  */
-function drush_unset_option($option, $context) {
-  $cache =& drush_get_context($context);
-  if (array_key_exists($option, $cache)) {
-    unset($cache[$option]);
+function drush_unset_option($option, $context = NULL) {
+  if ($context != NULL) {
+    $cache =& drush_get_context($context);
+    if (array_key_exists($option, $cache)) {
+      unset($cache[$option]);
+    }
+  }
+  else {
+    $contexts = _drush_context_names();
+
+    foreach ($contexts as $context) {
+      drush_unset_option($option, $context);
+    }
   }
 }
 
Index: includes/environment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/environment.inc,v
retrieving revision 1.62
diff -u -p -r1.62 environment.inc
--- includes/environment.inc	31 Dec 2009 14:04:23 -0000	1.62
+++ includes/environment.inc	1 Jan 2010 04:59:25 -0000
@@ -435,7 +435,14 @@ function _drush_bootstrap_drush() {
   if ($backend || $quiet) {
     ob_start();
   }
+  
+  _drush_bootstrap_global_options();
 
+  // Find any command files that are available during this bootstrap phase.
+  _drush_find_commandfiles(DRUSH_BOOTSTRAP_DRUSH);
+}
+
+function _drush_bootstrap_global_options() {
   // Debug implies verbose
   drush_set_context('DRUSH_VERBOSE',     drush_get_option(array('v', 'verbose', 'd', 'debug'), FALSE));
   drush_set_context('DRUSH_DEBUG', drush_get_option(array('d', 'debug')));
@@ -455,9 +462,6 @@ function _drush_bootstrap_drush() {
     $nocolor = !($colors === FALSE || (is_numeric($colors) && $colors >= 3));
   }
   drush_set_context('DRUSH_NOCOLOR', $nocolor);
-
-  // Find any command files that are available during this bootstrap phase.
-  _drush_find_commandfiles(DRUSH_BOOTSTRAP_DRUSH);
 }
 
 /**
