@@ -110,25 +110,30 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
110
110
$ eventFQCNList = array_filter (array_map ($ this ->eventRegistry ->getEventClassName (...), $ eventList ), fn ($ eventFQCN ) => \is_string ($ eventFQCN ));
111
111
$ eventIdAndFQCNList = array_unique (array_merge ($ eventList , $ eventFQCNList ));
112
112
$ suggestionList = [];
113
+
113
114
foreach ($ eventIdAndFQCNList as $ eventSuggestion ) {
114
115
if (levenshtein ($ event , Str::getShortClassName ($ eventSuggestion )) < 3 ) {
115
116
$ suggestionList [] = $ eventSuggestion ;
116
117
}
117
118
}
119
+
118
120
if (!$ suggestionList ) {
119
121
return ;
120
122
}
123
+
121
124
if (1 === \count ($ suggestionList )) {
122
125
$ question = new ConfirmationQuestion (sprintf ('<fg=green>Did you mean</> <fg=yellow>"%s"</> <fg=green>?</> ' , $ suggestionList [0 ]), false );
123
- $ event = $ io ->askQuestion ($ question ) ? $ suggestionList [0 ] : $ event ;
124
- } else {
125
- $ io ->writeln (' <fg=yellow>Did you mean one of these events?</> ' );
126
- $ io ->listing ($ suggestionList );
127
- $ question = new Question (sprintf (' <fg=green>%s</> ' , $ command ->getDefinition ()->getArgument ('event ' )->getDescription ()), $ event );
128
- $ question ->setAutocompleterValues (array_merge ($ suggestionList , [$ event ]));
129
- $ event = $ io ->askQuestion ($ question );
126
+ $ input ->setArgument ('event ' , $ io ->askQuestion ($ question ) ? $ suggestionList [0 ] : $ event );
127
+
128
+ return ;
130
129
}
131
- $ input ->setArgument ('event ' , $ event );
130
+
131
+ $ io ->writeln (' <fg=yellow>Did you mean one of these events?</> ' );
132
+ $ io ->listing ($ suggestionList );
133
+ $ question = new Question (sprintf (' <fg=green>%s</> ' , $ command ->getDefinition ()->getArgument ('event ' )->getDescription ()), $ event );
134
+ $ question ->setAutocompleterValues (array_merge ($ suggestionList , [$ event ]));
135
+
136
+ $ input ->setArgument ('event ' , $ io ->askQuestion ($ question ));
132
137
}
133
138
}
134
139
0 commit comments