Skip to content

Commit f1f9110

Browse files
Merge pull request #56 from BhargavBhandari90/issue/GH-53
Only display pagination message when `--format=table`
2 parents 6eade8f + c4e5be1 commit f1f9110

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

features/plugin-search.feature

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ Feature: Search WordPress.org plugins
33
Scenario: Search for plugins with active_installs field
44
Given a WP install
55

6-
When I run `wp plugin search foo --fields=name,slug,active_installs --format=csv`
6+
When I run `wp plugin search foo --fields=name,slug,active_installs`
77
Then STDOUT should contain:
88
"""
99
Success: Showing
1010
"""
11+
12+
When I run `wp plugin search foo --fields=name,slug,active_installs --format=csv`
13+
Then STDOUT should not contain:
14+
"""
15+
Success: Showing
16+
"""
1117
And STDOUT should contain:
1218
"""
1319
name,slug,active_installs

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ protected function _search( $args, $assoc_args ) {
585585
$fields[ $field ] = true;
586586
}
587587

588+
$format = ! empty( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
588589
$formatter = $this->get_formatter( $assoc_args );
589590

590591
$api_args = array(
@@ -610,8 +611,10 @@ protected function _search( $args, $assoc_args ) {
610611

611612
$items = $api->$plural;
612613

613-
$count = \WP_CLI\Utils\get_flag_value( $api->info, 'results', 'unknown' );
614-
\WP_CLI::success( sprintf( 'Showing %s of %s %s.', count( $items ), $count, $plural ) );
614+
if ( 'table' === $format ) {
615+
$count = \WP_CLI\Utils\get_flag_value( $api->info, 'results', 'unknown' );
616+
\WP_CLI::success( sprintf( 'Showing %s of %s %s.', count( $items ), $count, $plural ) );
617+
}
615618

616619
$formatter->display_items( $items );
617620
}

0 commit comments

Comments
 (0)