Skip to content

Commit

Permalink
Support --pipe with remote commands and alias lists
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Oct 30, 2011
1 parent 2f07c1b commit a472575
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
30 changes: 17 additions & 13 deletions drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,30 @@ function drush_main() {
// Process initial global options such as --debug.
_drush_bootstrap_global_options();

$return = '';
drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUSH);
// Process a remote command if 'remote-host' option is set.
$command_handled = drush_remote_command();
if (!$command_handled) {
$return = _drush_bootstrap_and_dispatch();
}

drush_bootstrap_finish();

// After this point the drush_shutdown function will run,
// exiting with the correct exit code.
return $return;
}

function _drush_bootstrap_and_dispatch() {
$phases = _drush_bootstrap_phases(FALSE, TRUE);

$return = '';
$command_found = FALSE;

_drush_bootstrap_output_prepare();
foreach ($phases as $phase) {
if (drush_bootstrap_to_phase($phase)) {
$command = drush_parse_command();

// Process a remote command if 'remote-host' option is set.
if (drush_remote_command()) {
$command_found = TRUE;
break;
}

if (is_array($command)) {
$bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
drush_enforce_requirement_bootstrap_phase($command);
Expand Down Expand Up @@ -114,11 +123,6 @@ function drush_main() {
drush_set_error($code, $message);
}
}

drush_bootstrap_finish();

// After this point the drush_shutdown function will run,
// exiting with the correct exit code.
return $return;
}

Expand Down
8 changes: 5 additions & 3 deletions includes/bootstrap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ function _drush_bootstrap_drush() {
}
}

_drush_bootstrap_global_options();
}

function _drush_bootstrap_output_prepare() {
$backend = drush_set_context('DRUSH_BACKEND', drush_get_option('backend'));

// Pipe implies quiet.
Expand Down Expand Up @@ -532,8 +536,6 @@ function _drush_bootstrap_drush() {
if ($quiet && !$backend) {
ob_start();
}

_drush_bootstrap_global_options();
}

/**
Expand Down Expand Up @@ -595,7 +597,7 @@ function _drush_bootstrap_global_options() {

// Backend implies affirmative unless negative is explicitly specified
drush_set_context('DRUSH_NEGATIVE', drush_get_option('no', FALSE));
drush_set_context('DRUSH_AFFIRMATIVE', drush_get_option('yes', FALSE) || (drush_get_context('DRUSH_BACKEND') && !drush_get_context('DRUSH_NEGATIVE')));
drush_set_context('DRUSH_AFFIRMATIVE', drush_get_option(array('yes', 'pipe'), FALSE) || (drush_get_context('DRUSH_BACKEND') && !drush_get_context('DRUSH_NEGATIVE')));
drush_set_context('DRUSH_SIMULATE', drush_get_option('simulate', FALSE));

// Suppress colored logging if --nocolor option is explicitly given or if
Expand Down
3 changes: 3 additions & 0 deletions includes/drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ function drush_remote_command() {
$command = array_shift($args);
$multi_options = drush_get_context('cli');
$backend_options = array();
if (drush_get_option('pipe')) {
$backend_options['interactive'] = TRUE;
}

if (!drush_get_option('no-label', FALSE) && !$interactive) {
$label_separator = ' >> ';
Expand Down

0 comments on commit a472575

Please sign in to comment.