Skip to content
Merged
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
Correct completion case when ends in =
  • Loading branch information
Roy-Orbison committed Mar 6, 2024
commit c9484bea498474635faf2e212476924e497ade2e
6 changes: 6 additions & 0 deletions features/cli-bash-completion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ Feature: `wp cli completions` tasks
"""

When I run `wp cli completions --line='wp config create --dbname=' --point=100`
Then STDOUT should not contain:
"""
--dbname=
"""

When I run `wp cli completions --line='wp config create --dbname' --point=100`
Then STDOUT should contain:
"""
--dbname=
Expand Down
4 changes: 2 additions & 2 deletions php/WP_CLI/Completions.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ private function get_command( $words ) {
end( $words );
$last_arg_i = key( $words );
foreach ( $words as $i => $arg ) {
if ( preg_match( '|^--([^=]+)=?|', $arg, $matches ) ) {
if ( $i === $last_arg_i ) {
if ( preg_match( '|^--([^=]+)(=?)|', $arg, $matches ) ) {
if ( $i === $last_arg_i && '' === $matches[2] ) {
continue;
}
$assoc_args[ $matches[1] ] = true;
Expand Down