Skip to content

Commit

Permalink
#886166 by greg.1.anderson: drush help sub-options
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Aug 18, 2010
1 parent bef9647 commit 1221b40
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 22 deletions.
56 changes: 38 additions & 18 deletions commands/pm/pm.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.',
Expand All @@ -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: <the drush command line used>',
' --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: <the drush command line used>',
'--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).'
Expand All @@ -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: <the drush command line used>',
),
'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: <the drush command line used>',
),
),
),
);
Expand Down
8 changes: 6 additions & 2 deletions commands/sql/sql.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions drush.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
}
}
Expand All @@ -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)";
}
}

Expand Down
1 change: 1 addition & 0 deletions includes/command.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions includes/drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down

0 comments on commit 1221b40

Please sign in to comment.