Skip to content

Commit 07ac222

Browse files
Accept plaintext as an alias of var_export in cli param-dump (#6339)
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
1 parent 65ed76a commit 07ac222

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎features/cli.feature‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ Feature: `wp cli` tasks
4141
And STDERR should be empty
4242
And the return code should be 0
4343

44+
Scenario: Dump the list of global parameters in plaintext format
45+
Given a WP installation
46+
47+
# `plaintext` is an accepted alias of `var_export` for this command (see #4774),
48+
# so it must emit the var_export representation, not JSON.
49+
When I run `wp cli param-dump --format=plaintext`
50+
Then STDOUT should contain:
51+
"""
52+
'path' =>
53+
"""
54+
And STDERR should be empty
55+
And the return code should be 0
56+
4457
Scenario: Checking whether a global configuration parameter exists or not
4558
Given a WP installation
4659
And a custom-cmd.php file:

‎php/commands/src/CLI_Command.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ private function array_find( $arr, $callback ) {
993993
* default: json
994994
* options:
995995
* - var_export
996+
* - plaintext
996997
* - json
997998
* ---
998999
*
@@ -1034,7 +1035,11 @@ public function param_dump( $_, $assoc_args ) {
10341035
}
10351036
}
10361037

1037-
if ( 'var_export' === Utils\get_flag_value( $assoc_args, 'format' ) ) {
1038+
// `plaintext` and `var_export` are the same format under two names; accept both
1039+
// so the format name is consistent with other commands. See
1040+
// https://github.com/wp-cli/wp-cli/issues/4774
1041+
$format = Utils\get_flag_value( $assoc_args, 'format' );
1042+
if ( 'var_export' === $format || 'plaintext' === $format ) {
10381043
var_export( $spec );
10391044
} else {
10401045
echo json_encode( $spec );

0 commit comments

Comments
 (0)