Skip to content

Commit 00ca209

Browse files
Add verbosity level and quiet flag in ssh command based on debug flag (#5869)
* Add verbosity level and quiet flag in ssh command based on debug flag * Remove redundant spaces from ssh command args * Update aliases and flags feature test * Apply suggestions from code review --------- Co-authored-by: Daniel Bachhuber <daniel@bachhuber.co>
1 parent 28803df commit 00ca209

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

features/aliases.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Feature: Create shortcuts to specific WordPress installs
186186
When I try `wp @foo --debug --version`
187187
Then STDERR should contain:
188188
"""
189-
Running SSH command: ssh -q -J 'proxyhost'
189+
Running SSH command: ssh -J 'proxyhost' -T -vvv
190190
"""
191191

192192
Scenario: Adds key to ssh command
@@ -201,7 +201,7 @@ Feature: Create shortcuts to specific WordPress installs
201201
When I try `wp @foo --debug --version`
202202
Then STDERR should contain:
203203
"""
204-
Running SSH command: ssh -q -i 'identityfile.key'
204+
Running SSH command: ssh -i 'identityfile.key' -T -vvv
205205
"""
206206

207207
Scenario: Add an alias

features/flags.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ Feature: Global flags
344344
When I try `WP_CLI_STRICT_ARGS_MODE=1 wp --debug --ssh=/ --version`
345345
Then STDERR should contain:
346346
"""
347-
Running SSH command: ssh -q -T '' 'WP_CLI_STRICT_ARGS_MODE=1 wp
347+
Running SSH command: ssh -T -vvv '' 'WP_CLI_STRICT_ARGS_MODE=1 wp
348348
"""
349349

350350
Scenario: SSH flag should support changing directories
351351
When I try `wp --debug --ssh=wordpress:/my/path --version`
352352
Then STDERR should contain:
353353
"""
354-
Running SSH command: ssh -q -T 'wordpress' 'cd '\''/my/path'\''; wp
354+
Running SSH command: ssh -T -vvv 'wordpress' 'cd '\''/my/path'\''; wp
355355
"""
356356

357357
Scenario: SSH flag should support Docker

php/WP_CLI/Runner.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ private function generate_ssh_command( $bits, $wp_command ) {
644644

645645
// Default scheme is SSH.
646646
if ( 'ssh' === $bits['scheme'] || null === $bits['scheme'] ) {
647-
$command = 'ssh -q %s %s %s';
647+
$command = 'ssh %s %s %s';
648648

649649
if ( $bits['user'] ) {
650650
$bits['host'] = $bits['user'] . '@' . $bits['host'];
@@ -660,10 +660,11 @@ private function generate_ssh_command( $bits, $wp_command ) {
660660
}
661661

662662
$command_args = [
663-
$bits['proxyjump'] ? sprintf( '-J %s ', escapeshellarg( $bits['proxyjump'] ) ) : '',
664-
$bits['port'] ? '-p ' . (int) $bits['port'] . ' ' : '',
663+
$bits['proxyjump'] ? sprintf( '-J %s', escapeshellarg( $bits['proxyjump'] ) ) : '',
664+
$bits['port'] ? sprintf( '-p %d', (int) $bits['port'] ) : '',
665665
$bits['key'] ? sprintf( '-i %s', escapeshellarg( $bits['key'] ) ) : '',
666666
$is_tty ? '-t' : '-T',
667+
WP_CLI::get_config( 'debug' ) ? '-vvv' : '-q',
667668
];
668669

669670
$escaped_command = sprintf(

0 commit comments

Comments
 (0)