mirror of
https://ghproxy.net/https://github.com/wp-cli/extension-command.git
synced 2025-10-04 06:06:59 +08:00
Only display pagination when format=table
This commit is contained in:
parent
5a1c7b0616
commit
5efaff7f16
2 changed files with 12 additions and 3 deletions
|
@ -3,11 +3,17 @@ Feature: Search WordPress.org plugins
|
|||
Scenario: Search for plugins with active_installs field
|
||||
Given a WP install
|
||||
|
||||
When I run `wp plugin search foo --fields=name,slug,active_installs --format=csv`
|
||||
When I run `wp plugin search foo --fields=name,slug,active_installs`
|
||||
Then STDOUT should contain:
|
||||
"""
|
||||
Success: Showing
|
||||
"""
|
||||
|
||||
When I run `wp plugin search foo --fields=name,slug,active_installs --format=csv`
|
||||
Then STDOUT should not contain:
|
||||
"""
|
||||
Success: Showing
|
||||
"""
|
||||
And STDOUT should contain:
|
||||
"""
|
||||
name,slug,active_installs
|
||||
|
|
|
@ -584,6 +584,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
|
|||
$fields[ $field ] = true;
|
||||
}
|
||||
|
||||
$format = ! empty( $assoc_args['format'] ) ? $assoc_args['format'] : 'table';
|
||||
$formatter = $this->get_formatter( $assoc_args );
|
||||
|
||||
$api_args = array(
|
||||
|
@ -609,8 +610,10 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
|
|||
|
||||
$items = $api->$plural;
|
||||
|
||||
if ( 'table' === $format ) {
|
||||
$count = \WP_CLI\Utils\get_flag_value( $api->info, 'results', 'unknown' );
|
||||
\WP_CLI::success( sprintf( 'Showing %s of %s %s.', count( $items ), $count, $plural ) );
|
||||
}
|
||||
|
||||
$formatter->display_items( $items );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue