Closed ernilambar closed 4 months ago
@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']
.
cc @danielbachhuber
@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.
Fixes https://github.com/wp-cli/entity-command/issues/474