Skip to content

Commit 1377185

Browse files
Display number of records found in query
1 parent b1fd4f4 commit 1377185

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

includes/wp-cli.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function query( $args, $assoc_args ) {
114114
$records = wp_stream_query( $query_args );
115115

116116
// Make structure Formatter compatible
117-
foreach ( $records as $key => $record ) {
117+
foreach ( (array) $records as $key => $record ) {
118118
$formatted_records[ $key ] = array();
119119

120120
foreach ( $record as $field_name => $field ) {
@@ -131,6 +131,12 @@ public function query( $args, $assoc_args ) {
131131
);
132132

133133
$formatter->display_items( $formatted_records );
134+
135+
if ( 0 === ( $found = count( $records ) ) ) {
136+
WP_CLI::line( 'No records found.' );
137+
} else {
138+
WP_CLI::line( sprintf( _n( '1 record found.', '%s records found.', $found, 'stream' ), number_format( $found ) ) );
139+
}
134140
}
135141

136142
/**

0 commit comments

Comments
 (0)