? includes/table.inc Index: commands/pm/pm.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/pm/pm.drush.inc,v retrieving revision 1.77 diff -u -p -r1.77 pm.drush.inc --- commands/pm/pm.drush.inc 19 Jan 2010 00:17:55 -0000 1.77 +++ commands/pm/pm.drush.inc 19 Jan 2010 14:17:39 -0000 @@ -104,7 +104,7 @@ function pm_drush_command() { ); $items['pm-list'] = array( 'description' => 'Show module enabled/disabled status', - 'callback' => 'pm_module_manage', + 'callback' => 'drush_pm_module_manage', 'callback arguments' => array(array(), FALSE), 'options' => array( '--pipe' => 'Returns a space delimited list of enabled modules.', @@ -184,7 +184,7 @@ function pm_drush_command() { */ function drush_pm_enable() { $args = func_get_args(); - return pm_module_manage($args, TRUE); + return drush_pm_module_manage($args, TRUE); } /** @@ -192,7 +192,7 @@ function drush_pm_enable() { */ function drush_pm_disable() { $args = func_get_args(); - return pm_module_manage($args, FALSE); + return drush_pm_module_manage($args, FALSE); } /** @@ -240,7 +240,7 @@ function drush_pm_uninstall() { } } -function pm_module_manage($modules = array(), $enable = TRUE) { +function drush_pm_module_manage($modules = array(), $enable = TRUE) { if (function_exists('module_load_include')) { module_load_include('inc', 'system', 'system.admin'); } Index: commands/simpletest/simpletest.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/simpletest/simpletest.drush.inc,v retrieving revision 1.5 diff -u -p -r1.5 simpletest.drush.inc --- commands/simpletest/simpletest.drush.inc 7 Jan 2010 14:15:16 -0000 1.5 +++ commands/simpletest/simpletest.drush.inc 19 Jan 2010 14:17:39 -0000 @@ -22,7 +22,6 @@ function simpletest_drush_help($section) */ function simpletest_drush_command() { $items['test-mail'] = array( - 'callback' => 'drush_test_mail', 'description' => 'Run all tests and mail the results to your team.', 'examples' => array( "drush test-mail me@example.com --extra=\"--class BlockTestCase\"" => "Run block tests & email to me.", @@ -39,13 +38,11 @@ function simpletest_drush_command() { 'core' => array('6','7'), ); $items['test-clean'] = array( - 'callback' => 'drush_test_clean', 'description' => 'Delete leftover tables and files from prior test runs.', 'drupal dependencies' => array('simpletest'), 'core' => array('6','7'), ); $items['test-drush'] = array( - 'callback' => 'drush_test_drush', 'description' => 'Run drush-specific tests', 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, ); @@ -53,14 +50,14 @@ function simpletest_drush_command() { } // A drush command callback. -function drush_test_clean() { +function drush_simpletest_test_clean() { simpletest_clean_environment(); drush_print("Simpletest environment successfully cleaned."); } // A Drush command callback. -function drush_test_mail($recipients) { +function drush_simpletest_test_mail($recipients) { $run_tests = './scripts/run-tests.sh'; if (!file_exists($run_tests)) { return drush_set_error('DRUSH_SIMPLETEST_RUNTESTS_SH', dt('You must copy or symlink run-tests.sh into your /scripts directory beneath Drupal root.')); @@ -101,7 +98,7 @@ function drush_simpletest_format_results * * http://drupal.org/node/483940 */ -function drush_test_drush() { +function drush_simpletest_test_drush() { drush_log(dt("Invoking %drush help in a subprocess", array('%drush' => DRUSH_COMMAND))); drush_backend_invoke('help', array(), 'GET', FALSE); -} \ No newline at end of file +} Index: includes/command.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/command.inc,v retrieving revision 1.57 diff -u -p -r1.57 command.inc --- includes/command.inc 19 Jan 2010 03:36:08 -0000 1.57 +++ includes/command.inc 19 Jan 2010 14:17:40 -0000 @@ -91,6 +91,7 @@ function drush_get_commands() { // Add some defaults and normalize the command descriptor $command += array( 'command' => $key, + 'command-hook' => $key, 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, 'commandfile' => $commandfile, 'path' => dirname($path), @@ -109,6 +110,19 @@ function drush_get_commands() { 'drush dependencies' => array(), 'bootstrap_errors' => array(), ); + // If command callback is correctly named, then fix + // up the command entry so that drush_invoke will be + // called. + if ($command['callback'] != 'drush_command') { + $required_command_prefix = 'drush_' . $commandfile . '_'; + if ((substr($command['callback'], 0, strlen($required_command_prefix)) == $required_command_prefix)) { + $command['command-hook'] = substr($command['callback'], strlen($required_command_prefix)); + $command['callback'] = 'drush_command'; + } + else { + $command['callback-required-prefix'] = $required_command_prefix; + } + } // Enforce the no-spaces in command names rule if ((!drush_get_option('allow-spaces-in-commands', FALSE)) && (strpos($key, ' ') !== FALSE)) { $command['must-replace-spaces'] = TRUE; @@ -346,7 +360,7 @@ function drush_command() { } if (!drush_get_error()) { - call_user_func_array('drush_invoke', array_merge(array($command['command']), $args)); + call_user_func_array('drush_invoke', array_merge(array($command['command-hook']), $args)); } if (!drush_get_error()) { Index: includes/drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/drush.inc,v retrieving revision 1.77 diff -u -p -r1.77 drush.inc --- includes/drush.inc 15 Jan 2010 00:44:59 -0000 1.77 +++ includes/drush.inc 19 Jan 2010 14:17:41 -0000 @@ -40,7 +40,14 @@ function drush_dispatch($command = NULL) return FALSE; } } + // Print a warning if a command callback function is misnamed + if (isset($command['callback-required-prefix'])) { + drush_log(dt('Warning: The command callback function !callback has a deprecated name. It must begin with !requiredprefix. Skipping hook functions.', array('!callback' => $command['callback'], '!requiredprefix' => $command['callback-required-prefix']))); + } // Call the callback function of the active command. + // TODO: If we make the required prefix actually required rather than just emitting a + // warning, then this could become a direct call to drush_command (all commands with + // the required prefix will now go through drush_command + drush_invoke). $return = call_user_func_array($command['callback'], $command['arguments']); }