entity-command icon indicating copy to clipboard operation
entity-command copied to clipboard

Introduce `--format=ids` in user application password list

Open ernilambar opened this issue 1 year ago • 3 comments

Fixes https://github.com/wp-cli/entity-command/issues/474

ernilambar avatar Feb 23 '24 06:02 ernilambar

@swissspidy In Formatter, $assoc_args is passed by reference.

public function __construct( &$assoc_args, $fields = null, $prefix = false ) {

And it unsets the format key in the method. https://github.com/wp-cli/wp-cli/blob/main/php/WP_CLI/Formatter.php#L46

So, if we keep $formatter = new Formatter( $assoc_args, $fields ); before the conditional, if condition will never be true because we now dont have $assoc_args['format'].

ernilambar avatar Feb 27 '24 05:02 ernilambar

cc @danielbachhuber

ernilambar avatar Mar 05 '24 05:03 ernilambar

@ernilambar I suggest to go with the tweak that @swissspidy mentioned but also combine it with an early processing of the flag like so:

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

This will avoid the breakage with @swissspidy 's refactor, and it will also make the conditional(s) cleaner.

schlessera avatar Mar 14 '24 08:03 schlessera