Skip to content

Commit f4eda28

Browse files
Copilotswissspidy
andcommitted
Simplify error message construction for better readability
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent dbbd8a3 commit f4eda28

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/Search_Replace_Command.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,13 @@ public function __invoke( $args, $assoc_args ) {
295295
if ( null === $new ) {
296296
$missing[] = '<new>';
297297
}
298-
$error_msg = 'Please provide both <old> and <new> arguments.';
299-
if ( count( $missing ) === 1 ) {
300-
$error_msg = sprintf( 'Please provide the %s argument.', $missing[0] );
301-
}
302-
$error_msg .= "\n\nNote: If your search or replacement string starts with '--', use the flag syntax instead:";
303-
$error_msg .= "\n wp search-replace --old='--text' --new='replacement'";
298+
$error_msg = count( $missing ) === 2
299+
? 'Please provide both <old> and <new> arguments.'
300+
: sprintf( 'Please provide the %s argument.', $missing[0] );
301+
302+
$error_msg .= "\n\nNote: If your search or replacement string starts with '--', use the flag syntax instead:"
303+
. "\n wp search-replace --old='--text' --new='replacement'";
304+
304305
WP_CLI::error( $error_msg );
305306
}
306307

0 commit comments

Comments
 (0)