diff --git a/features/ability.feature b/features/ability.feature index 81e230c..4718434 100644 --- a/features/ability.feature +++ b/features/ability.feature @@ -95,6 +95,13 @@ Feature: Manage abilities registered via the WordPress Abilities API. "name":"test-plugin\/get-site-title" """ + When I run `wp ability list --category=test-category --format=ids` + Then STDOUT should be: + """ + test-plugin/get-site-title test-plugin/echo-input + """ + And STDERR should be empty + @require-wp-6.9 Scenario: Get ability details. Given a wp-content/mu-plugins/test-ability.php file: diff --git a/src/Ability_Command.php b/src/Ability_Command.php index 3a21351..90fc993 100644 --- a/src/Ability_Command.php +++ b/src/Ability_Command.php @@ -242,6 +242,12 @@ public function list_( $args, $assoc_args ): void { } $formatter = $this->get_formatter( $assoc_args, $this->default_fields ); + + // The ids format expects plain values, so pass the ability names. + if ( 'ids' === $formatter->format ) { + $items = wp_list_pluck( $items, 'name' ); + } + $formatter->display_items( $items ); }