Skip to content

Commit 554eaa3

Browse files
Copilotswissspidy
andcommitted
Fix dry-run with summary format to produce no output
The logic for handling --dry-run with --format=summary was incorrect. It was outputting the message and table, but the tests expect empty output. Fixed the condition to: - json/csv formats: output formatted data only - table or no format: output message and table - summary format: no output (as per test expectations) Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 715eb3e commit 554eaa3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/WP_CLI/CommandWithTranslation.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ public function update( $args, $assoc_args ) {
150150
if ( Utils\get_flag_value( $assoc_args, 'dry-run' ) ) {
151151
$update_count = count( $updates );
152152

153-
if ( $format && ! in_array( $format, array( 'table', 'summary' ), true ) ) {
153+
if ( $format && in_array( $format, array( 'json', 'csv' ), true ) ) {
154154
// For json/csv formats, just output the formatted data without the message
155155
Utils\format_items( $format, $updates, array( 'Type', 'Name', 'Version', 'Language' ) );
156-
} else {
157-
// For table/summary/no format, show the message and table
156+
} elseif ( ! $format || 'table' === $format ) {
157+
// For table or no format, show the message and table
158158
WP_CLI::line(
159159
sprintf(
160160
'Found %d translation %s that would be processed:',
@@ -165,6 +165,7 @@ public function update( $args, $assoc_args ) {
165165

166166
Utils\format_items( 'table', $updates, array( 'Type', 'Name', 'Version', 'Language' ) );
167167
}
168+
// For 'summary' format, do nothing (no output for dry-run mode)
168169

169170
return;
170171
}

0 commit comments

Comments
 (0)