diff --git a/features/plugin.feature b/features/plugin.feature index 90fbae31..8153e320 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -407,6 +407,30 @@ Feature: Manage WordPress plugins | akismet | active | akismet/akismet.php | | wordpress-importer | inactive | wordpress-importer/wordpress-importer.php | + When I run `wp plugin list --status=active --status=inactive --fields=name,status,file` + Then STDOUT should be a table containing rows: + | name | status | file | + | akismet | active | akismet/akismet.php | + | wordpress-importer | inactive | wordpress-importer/wordpress-importer.php | + + Scenario: Filter plugin list by multiple names + Given a WP install + + When I run `wp plugin install wordpress-importer --ignore-requirements` + Then STDOUT should not be empty + + When I run `wp plugin list --name=akismet,wordpress-importer --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | akismet | inactive | + | wordpress-importer | inactive | + + When I run `wp plugin list --name=akismet --name=wordpress-importer --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | akismet | inactive | + | wordpress-importer | inactive | + @require-wp-5.2 Scenario: Flag `--skip-update-check` skips update check when running `wp plugin list` Given a WP install diff --git a/features/theme.feature b/features/theme.feature index 591a0d87..53ea0303 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -807,3 +807,33 @@ Feature: Manage WordPress themes """ classic """ + + Scenario: Filter theme list by multiple names + Given a WP install + And I run `wp theme delete --all --force` + And I run `wp theme install twentyeleven --activate` + And I run `wp theme install twentytwelve` + + When I run `wp theme list --name=twentytwelve,twentyeleven --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | twentyeleven | active | + | twentytwelve | inactive | + + When I run `wp theme list --name=twentytwelve --name=twentyeleven --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | twentyeleven | active | + | twentytwelve | inactive | + + When I run `wp theme list --status=active,inactive --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | twentyeleven | active | + | twentytwelve | inactive | + + When I run `wp theme list --status=active --status=inactive --fields=name,status` + Then STDOUT should be a table containing rows: + | name | status | + | twentyeleven | active | + | twentytwelve | inactive | diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 0fb12a8c..f5c49baf 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -1872,7 +1872,7 @@ public function delete( $args, $assoc_args ) { * - yaml * --- * - * [--status=] + * [--status=...] * : Filter the output by plugin status. * --- * options: diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 7ea769c1..a087b202 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -1021,7 +1021,7 @@ public function delete( $args, $assoc_args ) { * - yaml * --- * - * [--status=] + * [--status=...] * : Filter the output by theme status. * --- * options: diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 01b646d6..2dfc36cc 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -926,10 +926,16 @@ function ( $value ) { continue; } - // This can be either a value to filter by or a comma-separated list of values. - // Also, it is not forbidden for a value to contain a comma (in which case we can filter only by one). $field_filter = $assoc_args[ $field ]; - if ( + if ( is_array( $field_filter ) ) { + // Multiple values passed by repeating the argument (e.g., --name=plugin1 --name=plugin2). + /** @var string[] $field_filter */ + if ( ! in_array( $item[ $field ], $field_filter, true ) ) { + unset( $all_items[ $key ] ); + } + } elseif ( + // This can be either a value to filter by or a comma-separated list of values. + // Also, it is not forbidden for a value to contain a comma (in which case we can filter only by one). $item[ $field ] !== $field_filter && ! in_array( $item[ $field ], array_map( 'trim', explode( ',', $field_filter ) ), true ) ) {