Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions features/cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ Feature: `wp cli` tasks
And STDERR should be empty
And the return code should be 0

Scenario: Dump the list of global parameters in plaintext format
Given a WP installation

# `plaintext` is an accepted alias of `var_export` for this command (see #4774),
# so it must emit the var_export representation, not JSON.
When I run `wp cli param-dump --format=plaintext`
Then STDOUT should contain:
"""
'path' =>
"""
And STDERR should be empty
And the return code should be 0

Scenario: Checking whether a global configuration parameter exists or not
Given a WP installation
And a custom-cmd.php file:
Expand Down
7 changes: 6 additions & 1 deletion php/commands/src/CLI_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ private function array_find( $arr, $callback ) {
* default: json
* options:
* - var_export
* - plaintext
* - json
* ---
*
Expand Down Expand Up @@ -890,7 +891,11 @@ public function param_dump( $_, $assoc_args ) {
}
}

if ( 'var_export' === Utils\get_flag_value( $assoc_args, 'format' ) ) {
// `plaintext` and `var_export` are the same format under two names; accept both
// so the format name is consistent with other commands. See
// https://github.com/wp-cli/wp-cli/issues/4774
$format = Utils\get_flag_value( $assoc_args, 'format' );
if ( 'var_export' === $format || 'plaintext' === $format ) {
var_export( $spec );
} else {
echo json_encode( $spec );
Expand Down
Loading