From 633fa66d18a8baf9d302a0b31c80fd2b7ea617d1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:40:10 +0000 Subject: [PATCH 1/7] Initial plan From baf5d0cdd9aa8480a618b1e22db1c52b80509824 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:43:52 +0000 Subject: [PATCH 2/7] Implement quiet mode for shell command Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/shell.feature | 46 +++++++++++++++++++++++++++++++++++++++ src/Shell_Command.php | 8 ++++++- src/WP_CLI/Shell/REPL.php | 11 +++++++--- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/features/shell.feature b/features/shell.feature index 6cf104ce..fb187641 100644 --- a/features/shell.feature +++ b/features/shell.feature @@ -113,3 +113,49 @@ Feature: WordPress REPL Error: The 'shutdown' hook has not fired yet """ And the return code should be 1 + + Scenario: Quiet mode suppresses return value output + Given a WP install + And a session file: + """ + $a = "hello"; + """ + + When I run `wp shell --basic --quiet < session` + Then STDOUT should be empty + + Scenario: Quiet mode still shows echo output + Given a WP install + And a session file: + """ + echo "test output"; + """ + + When I run `wp shell --basic --quiet < session` + Then STDOUT should contain: + """ + test output + """ + + Scenario: Quiet mode with expression + Given a WP install + And a session file: + """ + get_bloginfo('name'); + """ + + When I run `wp shell --basic --quiet < session` + Then STDOUT should be empty + + Scenario: Normal mode shows return value + Given a WP install + And a session file: + """ + $a = "hello"; + """ + + When I run `wp shell --basic < session` + Then STDOUT should contain: + """ + string(5) "hello" + """ diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 7c89a7b2..30324b22 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -36,6 +36,11 @@ class Shell_Command extends WP_CLI_Command { * * # Start a shell, ensuring the 'init' hook has already fired. * $ wp shell --hook=init + * + * # Start a shell in quiet mode, suppressing return value output. + * $ wp shell --quiet + * wp> $a = "hello"; + * wp> */ public function __invoke( $_, $assoc_args ) { $hook = Utils\get_flag_value( $assoc_args, 'hook', '' ); @@ -71,6 +76,7 @@ public function __invoke( $_, $assoc_args ) { */ private function start_shell( $assoc_args ) { $class = WP_CLI\Shell\REPL::class; + $quiet = WP_CLI::get_config( 'quiet' ); $implementations = array( \Psy\Shell::class, @@ -98,7 +104,7 @@ private function start_shell( $assoc_args ) { /** * @var class-string $class */ - $repl = new $class( 'wp> ' ); + $repl = new $class( 'wp> ', $quiet ); $repl->start(); } } diff --git a/src/WP_CLI/Shell/REPL.php b/src/WP_CLI/Shell/REPL.php index 9415fc96..011f73c4 100644 --- a/src/WP_CLI/Shell/REPL.php +++ b/src/WP_CLI/Shell/REPL.php @@ -10,8 +10,11 @@ class REPL { private $history_file; - public function __construct( $prompt ) { + private $quiet; + + public function __construct( $prompt, $quiet = false ) { $this->prompt = $prompt; + $this->quiet = $quiet; $this->set_history_file(); } @@ -49,8 +52,10 @@ public function start() { if ( 0 < strlen( $out ) ) { echo rtrim( $out, "\n" ) . "\n"; } - echo '=> '; - var_dump( $evl ); + if ( ! $this->quiet ) { + echo '=> '; + var_dump( $evl ); + } fwrite( STDOUT, (string) ob_get_clean() ); } } From eda9826ee56d8b11024276702d8003ac1658aaf6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:44:47 +0000 Subject: [PATCH 3/7] Fix boolean type casting for quiet flag Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Shell_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 30324b22..65eb5eac 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -76,7 +76,7 @@ public function __invoke( $_, $assoc_args ) { */ private function start_shell( $assoc_args ) { $class = WP_CLI\Shell\REPL::class; - $quiet = WP_CLI::get_config( 'quiet' ); + $quiet = (bool) WP_CLI::get_config( 'quiet' ); $implementations = array( \Psy\Shell::class, From 583d60362b949f6eb3c0de04a5c33d4818a567a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 19:54:30 +0000 Subject: [PATCH 4/7] Fix Boris REPL compatibility by only passing quiet flag to built-in REPL Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Shell_Command.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 65eb5eac..ca702d61 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -100,6 +100,9 @@ private function start_shell( $assoc_args ) { if ( \Psy\Shell::class === $class ) { $shell = new Psy\Shell(); $shell->run(); + } elseif ( \Boris\Boris::class === $class ) { + $boris = new \Boris\Boris( 'wp> ' ); + $boris->start(); } else { /** * @var class-string $class From 718d2116eb9ecf21c4bb2bbae4b4bff9202287fa Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 23 Feb 2026 13:18:58 +0100 Subject: [PATCH 5/7] Update src/WP_CLI/Shell/REPL.php --- src/WP_CLI/Shell/REPL.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/WP_CLI/Shell/REPL.php b/src/WP_CLI/Shell/REPL.php index 011f73c4..21cdec0a 100644 --- a/src/WP_CLI/Shell/REPL.php +++ b/src/WP_CLI/Shell/REPL.php @@ -12,6 +12,10 @@ class REPL { private $quiet; + /** + * @param string $prompt Prompt to display. + * @param bool $quiet Whether to suppress automatic output. + */ public function __construct( $prompt, $quiet = false ) { $this->prompt = $prompt; $this->quiet = $quiet; From 2512c9ca6d5d6aa4546e889ad145b3ffbef33380 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 23 Feb 2026 13:19:14 +0100 Subject: [PATCH 6/7] Update src/WP_CLI/Shell/REPL.php --- src/WP_CLI/Shell/REPL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WP_CLI/Shell/REPL.php b/src/WP_CLI/Shell/REPL.php index 21cdec0a..e1e1a6fc 100644 --- a/src/WP_CLI/Shell/REPL.php +++ b/src/WP_CLI/Shell/REPL.php @@ -10,6 +10,7 @@ class REPL { private $history_file; + /** @var bool Whether to suppress automatic output. */ private $quiet; /** From 7a7031e220552e5117e1fe91db94e390f5961dd4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:22:07 +0000 Subject: [PATCH 7/7] Fix output buffering logic to properly capture echo and var_dump output Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/WP_CLI/Shell/REPL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WP_CLI/Shell/REPL.php b/src/WP_CLI/Shell/REPL.php index e1e1a6fc..67e55c54 100644 --- a/src/WP_CLI/Shell/REPL.php +++ b/src/WP_CLI/Shell/REPL.php @@ -57,6 +57,7 @@ public function start() { if ( 0 < strlen( $out ) ) { echo rtrim( $out, "\n" ) . "\n"; } + ob_start(); if ( ! $this->quiet ) { echo '=> '; var_dump( $evl );