Skip to content

Commit

Permalink
Merge pull request #475 from ernilambar/474-format-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored Apr 26, 2024
2 parents 55f8309 + 248cbb9 commit 8b19b7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions features/user-application-password.feature
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ Feature: Manage user custom fields
myapp2
"""

When I run `wp user application-password list 1 --format=ids --orderby=created --order=asc`
Then STDOUT should be:
"""
{UUID1} {UUID2}
"""

@require-wp-5.6
Scenario: Get particular user application password hash
Given a WP install
Expand Down
10 changes: 9 additions & 1 deletion src/User_Application_Password_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ final class User_Application_Password_Command {
* - json
* - count
* - yaml
* - ids
* ---
*
* [--orderby=<fields>]
Expand Down Expand Up @@ -197,8 +198,15 @@ static function ( $application_password ) use ( $field, $value ) {
$fields = explode( ',', $assoc_args['fields'] );
}

$format = Utils\get_flag_value( $assoc_args, 'format', 'table' );

$formatter = new Formatter( $assoc_args, $fields );
$formatter->display_items( $application_passwords );

if ( 'ids' === $format ) {
$formatter->display_items( wp_list_pluck( $application_passwords, 'uuid' ) );
} else {
$formatter->display_items( $application_passwords );
}
}

/**
Expand Down

0 comments on commit 8b19b7d

Please sign in to comment.