File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,10 @@ 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 be empty
104+ Then STDOUT should contain:
105+ """
106+ --dbname=
107+ """
105108
106109 When I run `wp cli completions --line='wp config create --dbname=foo ' --point=100`
107110 Then STDOUT should not contain:
@@ -321,7 +324,10 @@ Feature: `wp cli completions` tasks
321324 """
322325
323326 When I run `wp cli completions --line="wp core download --no-color" --point=100`
324- Then STDOUT should not contain:
327+ Then STDOUT should contain:
325328 """
326329 --no-color
327330 """
331+
332+ When I run `wp cli completions --line="wp core download --no-color --no-color" --point=100`
333+ Then STDOUT should be empty
Original file line number Diff line number Diff line change @@ -116,8 +116,14 @@ private function get_command( $words ) {
116116 $ positional_args = [];
117117 $ assoc_args = [];
118118
119- foreach ( $ words as $ arg ) {
119+ # Avoid having to polyfill array_key_last().
120+ end ( $ words );
121+ $ last_arg_i = key ( $ words );
122+ foreach ( $ words as $ i => $ arg ) {
120123 if ( preg_match ( '|^--([^=]+)=?| ' , $ arg , $ matches ) ) {
124+ if ( $ i === $ last_arg_i ) {
125+ continue ;
126+ }
121127 $ assoc_args [ $ matches [1 ] ] = true ;
122128 } else {
123129 $ positional_args [] = $ arg ;
You can’t perform that action at this time.
0 commit comments