Skip to content

Commit 8b19b7d

Browse files
authored
Merge pull request #475 from ernilambar/474-format-ids
2 parents 55f8309 + 248cbb9 commit 8b19b7d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

features/user-application-password.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ Feature: Manage user custom fields
244244
myapp2
245245
"""
246246

247+
When I run `wp user application-password list 1 --format=ids --orderby=created --order=asc`
248+
Then STDOUT should be:
249+
"""
250+
{UUID1} {UUID2}
251+
"""
252+
247253
@require-wp-5.6
248254
Scenario: Get particular user application password hash
249255
Given a WP install

src/User_Application_Password_Command.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ final class User_Application_Password_Command {
9797
* - json
9898
* - count
9999
* - yaml
100+
* - ids
100101
* ---
101102
*
102103
* [--orderby=<fields>]
@@ -197,8 +198,15 @@ static function ( $application_password ) use ( $field, $value ) {
197198
$fields = explode( ',', $assoc_args['fields'] );
198199
}
199200

201+
$format = Utils\get_flag_value( $assoc_args, 'format', 'table' );
202+
200203
$formatter = new Formatter( $assoc_args, $fields );
201-
$formatter->display_items( $application_passwords );
204+
205+
if ( 'ids' === $format ) {
206+
$formatter->display_items( wp_list_pluck( $application_passwords, 'uuid' ) );
207+
} else {
208+
$formatter->display_items( $application_passwords );
209+
}
202210
}
203211

204212
/**

0 commit comments

Comments
 (0)