Skip to content

Commit c9484be

Browse files
committed
Correct completion case when ends in =
1 parent 52751b1 commit c9484be

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

features/cli-bash-completion.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ Feature: `wp cli completions` tasks
101101
"""
102102

103103
When I run `wp cli completions --line='wp config create --dbname=' --point=100`
104+
Then STDOUT should not contain:
105+
"""
106+
--dbname=
107+
"""
108+
109+
When I run `wp cli completions --line='wp config create --dbname' --point=100`
104110
Then STDOUT should contain:
105111
"""
106112
--dbname=

php/WP_CLI/Completions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ private function get_command( $words ) {
120120
end( $words );
121121
$last_arg_i = key( $words );
122122
foreach ( $words as $i => $arg ) {
123-
if ( preg_match( '|^--([^=]+)=?|', $arg, $matches ) ) {
124-
if ( $i === $last_arg_i ) {
123+
if ( preg_match( '|^--([^=]+)(=?)|', $arg, $matches ) ) {
124+
if ( $i === $last_arg_i && '' === $matches[2] ) {
125125
continue;
126126
}
127127
$assoc_args[ $matches[1] ] = true;

0 commit comments

Comments
 (0)