Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Accept plaintext as an alias of var_export in cli param-dump
`plaintext` and `var_export` are the same plain-text output format under two
names across WP-CLI commands. `cli param-dump` only honored `var_export`, so
`--format=plaintext` silently fell through to JSON. Accept both names (and list
`plaintext` in the documented options) so the format is consistent with the
single-value formatters, which already alias the two.

Adds a functional test asserting `--format=plaintext` emits the var_export
representation.

Refs #4774
  • Loading branch information
thisismyurl committed Jun 30, 2026
commit 44f06449ff9d94b6dc72da0b177a6ef29e686049
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