diff --git a/commands/pm/pm.drush.inc b/commands/pm/pm.drush.inc index 84b4886175..d915a5a3cb 100644 --- a/commands/pm/pm.drush.inc +++ b/commands/pm/pm.drush.inc @@ -97,10 +97,14 @@ function pm_drush_command() { ); $update_options = array( '--lock' => 'Add a persistent lock to remove the specified projects from consideration during updates. Locks may be removed with the --unlock parameter, or overridden by specifically naming the module as a parameter to pm-update or pm-updatecode. The lock does not affect pm-download.', - '--lock-message' => 'A brief message explaining why a project is being locked; displayed during pm-updatecode. Optional.', - '--unlock' => 'Remove the persistent lock from the specified projects so that they may be updated again.', '--backup-dir' => 'Specify a directory to backup packages into, defaults to a backup directory within your Drupal root.', ); + $update_suboptions = array( + '--lock' => array( + '--lock-message' => 'A brief message explaining why a project is being locked; displayed during pm-updatecode. Optional.', + '--unlock' => 'Remove the persistent lock from the specified projects so that they may be updated again.', + ), + ); $items['pm-enable'] = array( 'description' => 'Enable one or more modules or themes.', @@ -163,6 +167,7 @@ function pm_drush_command() { 'options' => array( '--pipe' => 'Returns a space delimited list of enabled modules and their respective version and update information, one module per line. Order: module name, current version, recommended version, update status.', ) + $update_options, + 'sub-options' => $update_suboptions, 'aliases' => array('upc'), 'deprecated-aliases' => array('updatecode'), ) + $engines; @@ -1158,10 +1163,13 @@ function pm_drush_engine_package_handler() { 'cvs' => array( 'options' => array( '--package-handler=cvs' => 'Use CVS to checkout and update projects.', - ' --cvsparams' => 'Add options to the `cvs` program', - ' --cvsmethod' => 'Force cvs updates or checkouts (checkout is default unless the directory is managed by a supported version control system).', - ' --cvscredentials' => 'A username and password that is sent for cvs checkout command. Defaults to anonymous:anonymous', - + ), + 'sub-options' => array( + '--package-handler=cvs' => array( + '--cvsparams' => 'Add options to the `cvs` program', + '--cvsmethod' => 'Force cvs updates or checkouts (checkout is default unless the directory is managed by a supported version control system).', + '--cvscredentials' => 'A username and password that is sent for cvs checkout command. Defaults to anonymous:anonymous', + ), ), 'examples' => array( 'drush [command] cck --cvscredentials=\"name:password\"' => 'Checkout should use these credentials.', @@ -1181,14 +1189,18 @@ function pm_drush_engine_version_control() { 'signature' => 'svn info %s', 'options' => array( '--version-control=svn' => 'Quickly add/remove/commit your project changes to Subversion.', - ' --svnsync' => 'Automatically add new files to the SVN repository and remove deleted files. Caution.', - ' --svncommit' => 'Automatically commit changes to SVN repository. You must also using the --svnsync option.', - ' --svnmessage' => 'Override default commit message which is: Drush automatic commit: ', - ' --svnstatusparams' => "Add options to the 'svn status' command", - ' --svnaddparams' => 'Add options to the `svn add` command', - ' --svnremoveparams' => 'Add options to the `svn remove` command', - ' --svnrevertparams' => 'Add options to the `svn revert` command', - ' --svncommitparams' => 'Add options to the `svn commit` command', + ), + 'sub-options' => array( + '--version-control=svn' => array( + '--svnsync' => 'Automatically add new files to the SVN repository and remove deleted files. Caution.', + '--svncommit' => 'Automatically commit changes to SVN repository. You must also using the --svnsync option.', + '--svnmessage' => 'Override default commit message which is: Drush automatic commit: ', + '--svnstatusparams' => "Add options to the 'svn status' command", + '--svnaddparams' => 'Add options to the `svn add` command', + '--svnremoveparams' => 'Add options to the `svn remove` command', + '--svnrevertparams' => 'Add options to the `svn revert` command', + '--svncommitparams' => 'Add options to the `svn commit` command', + ), ), 'examples' => array( 'drush [command] cck --svncommitparams=\"--username joe\"' => 'Commit changes as the user \'joe\' (Quotes are required).' @@ -1197,16 +1209,24 @@ function pm_drush_engine_version_control() { 'backup' => array( 'options' => array( '--version-control=backup' => 'Backup all project files before updates.', - ' --backup-dir' => 'Backup destination directory. Defaults to a "/backup" subdirectory inside your Drupal root.', + ), + 'sub-options' => array( + '--version-control=backup' => array( + '--backup-dir' => 'Backup destination directory. Defaults to a "/backup" subdirectory inside your Drupal root.', + ), ), ), 'bzr' => array( 'signature' => 'bzr root %s', 'options' => array( '--version-control=bzr' => 'Quickly add/remove/commit your project changes to Bazaar.', - ' --bzrsync' => 'Automatically add new files to the Bazaar repository and remove deleted files. Caution.', - ' --bzrcommit' => 'Automatically commit changes to Bazaar repository. You must also using the --bzrsync option.', - ' --bzrmessage' => 'Override default commit message which is: Drush automatic commit: ', + ), + 'sub-options' => array( + '--version-control=bzr' => array( + '--bzrsync' => 'Automatically add new files to the Bazaar repository and remove deleted files. Caution.', + '--bzrcommit' => 'Automatically commit changes to Bazaar repository. You must also using the --bzrsync option.', + '--bzrmessage' => 'Override default commit message which is: Drush automatic commit: ', + ), ), ), ); diff --git a/commands/sql/sql.drush.inc b/commands/sql/sql.drush.inc index 1ef3a62763..18cc5b8b97 100644 --- a/commands/sql/sql.drush.inc +++ b/commands/sql/sql.drush.inc @@ -116,8 +116,12 @@ function sql_drush_command() { '--db-su' => 'Account to use when creating a new database. Optional.', '--db-su-pw' => 'Password for the "db-su" account. Optional.', '--sanitize' => 'Obscure email addresses and reset passwords in the user table post-sync. Optional.', - ' --sanitize-password' => 'The password to assign to all accounts in the sanitization operation, or "no" to keep passwords unchanged. Default is "password".', - ' --sanitize-email' => 'The username for test email addresses in the sanitization operation, or "no" to keep email addresses unchanged. May contain replacement patterns %uid, %mail or %login. Default is "user+%uid@localhost".', + ), + 'sub-options' => array( + '--sanitize' => array( + '--sanitize-password' => 'The password to assign to all accounts in the sanitization operation, or "no" to keep passwords unchanged. Default is "password".', + '--sanitize-email' => 'The username for test email addresses in the sanitization operation, or "no" to keep email addresses unchanged. May contain replacement patterns %uid, %mail or %login. Default is "user+%uid@localhost".', + ), ), ); if (drush_drupal_major_version() >= 7) { diff --git a/drush.api.php b/drush.api.php index 3aa9f2d122..f1fd1978d8 100644 --- a/drush.api.php +++ b/drush.api.php @@ -188,8 +188,8 @@ function hook_drush_pm_adjust_download_destination(&$project, $release) { */ function drush_hook_pre_sql_sync($source = NULL, $destination = NULL) { if (drush_get_option(array('sanitize', 'destination-sanitize'), FALSE)) { - drush_sql_register_post_sync_op('my-sanitize-id', - dt('Reset passwords and email addresses in user table'), + drush_sql_register_post_sync_op('my-sanitize-id', + dt('Reset passwords and email addresses in user table'), "update users set pass = MD5('password'), mail = concat('user+', uid, '@localhost') where uid > 0;"); } } @@ -200,6 +200,7 @@ function drush_hook_pre_sql_sync($source = NULL, $destination = NULL) { function hook_drush_help_alter(&$command) { if ($command['command'] == 'sql-sync') { $command['options']['--myoption'] = "Description of modification of sql-sync done by hook"; + $command['sub-options']['--sanitize']['--my-sanitize-option'] = "Description of sanitization option added by hook (grouped with --sanitize option)"; } } diff --git a/includes/command.inc b/includes/command.inc index 510fc96c83..d850b20b99 100644 --- a/includes/command.inc +++ b/includes/command.inc @@ -189,6 +189,7 @@ function drush_get_commands() { */ function drush_parse_command() { $args = drush_get_arguments(); + $command = FALSE; // Get a list of all implemented commands. $implemented = drush_get_commands(); diff --git a/includes/drush.inc b/includes/drush.inc index 6eb6e67bd6..26ea6a977d 100644 --- a/includes/drush.inc +++ b/includes/drush.inc @@ -690,6 +690,13 @@ function drush_show_help($commandstring) { foreach ($command[$key] as $name => $description) { // '[command] is a token representing the current command. @see pm_drush_engine_version_control(). $rows[] = array(str_replace('[command]', $commandstring, $name), dt($description)); + + // Process the subsections too, if any + if (!empty($command['sub-' . $key]) && array_key_exists($name, $command['sub-' . $key])) { + foreach ($command['sub-' . $key][$name] as $name => $description) { + $rows[] = array(' ' . str_replace('[command]', $commandstring, $name), dt($description)); + } + } } drush_print_table($rows, false, array(40)); unset($rows); @@ -713,6 +720,7 @@ function drush_show_help($commandstring) { return drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt('Invalid command !command.', array('!command' => $commandstring))); } + /** * Executes a shell command at a new working directory. * The old cwd is restored on exit.