Skip to content

Commit 3efe562

Browse files
committed
Merge pull request #488 from pantheon-systems/silence_drush
Made Drush and WP-CLI silent when running in --silent mode
2 parents 7a711cd + 6f6852b commit 3efe562

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

php/Terminus/CommandWithSSH.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ protected function send_command($server, $remote_exec, $args, $assoc_args) {
2929
}
3030

3131
$cmd = 'ssh -T ' . $server['user'] . '@' . $server['host'] . ' -p ' . $server['port'] . ' -o "AddressFamily inet"' . " " . escapeshellarg($remote_cmd);
32+
if (\Terminus::get_config('silent')) {
33+
ob_start();
34+
}
35+
passthru($cmd, $exit_code);
36+
if (\Terminus::get_config('silent')) {
37+
$this->logger->info(ob_get_clean());
38+
}
3239

33-
passthru( $cmd, $exit_code );
3440
if ($exit_code == 255) {
35-
\Terminus::error("Failed to connect. Check your credentials, and that you are specifying a valid environment.");
41+
$this->logger->error("Failed to connect. Check your credentials, and that you are specifying a valid environment.");
3642
}
3743
return( $exit_code );
3844
}

php/commands/drush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function __invoke( $args, $assoc_args ) {
6363
$flags .= "--$k ";
6464
}
6565
}
66-
Terminus::line( "Running drush %s %s on %s-%s", array($command, $flags, $site->get('name'), $environment));
66+
$this->logger->info( "Running drush %s %s on %s-%s", array($command, $flags, $site->get('name'), $environment));
6767
$this->send_command($server, 'drush', $args, $assoc_args );
6868
}
6969

php/commands/wp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function __invoke( $args, $assoc_args ) {
6262
$flags .= "--$k ";
6363
}
6464
}
65-
Terminus::line( "Running wp %s %s on %s-%s", array($command,$flags,$site->get('name'),$environment));
65+
$this->logger->info( "Running wp %s %s on %s-%s", array($command,$flags,$site->get('name'),$environment));
6666
$this->send_command($server, 'wp', $args, $assoc_args );
6767

6868
}

0 commit comments

Comments
 (0)