Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96aa999

Browse files
committed
Handle old config syntax gracefully
`wp config get --global=<global>` => `wp config get <name> --type=variable` `wp config get --constant=<constant>` => `wp config get <name> --type=constant` `wp config get` => `wp config list` Fixes wp-cli#43
1 parent d790e72 commit 96aa999

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

php/WP_CLI/Runner.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,29 @@ private static function back_compat_conversions( $args, $assoc_args ) {
728728
}
729729
}
730730

731+
// config get --[global|constant]=<global|constant> --> config get <name> --type=constant|variable
732+
// config get --> config list
733+
if ( count( $args ) === 2
734+
&& 'config' === $args[0]
735+
&& 'get' === $args[1] ) {
736+
if ( isset( $assoc_args['global'] ) ) {
737+
$name = $assoc_args['global'];
738+
$type = 'variable';
739+
unset( $assoc_args['global'] );
740+
} else if ( isset( $assoc_args['constant'] ) ) {
741+
$name = $assoc_args['constant'];
742+
$type = 'constant';
743+
unset( $assoc_args['constant'] );
744+
}
745+
if ( ! empty( $name ) && ! empty( $type ) ) {
746+
$args[] = $name;
747+
$assoc_args['type'] = $type;
748+
} else {
749+
// We had a 'config get' without a '<name>', so assume 'list' was wanted.
750+
$args[1] = 'list';
751+
}
752+
}
753+
731754
return array( $args, $assoc_args );
732755
}
733756

0 commit comments

Comments
 (0)