@@ -303,7 +303,7 @@ public function dispatch(string $name, array $args = [])
303303
304304 // is command
305305 if ($ info ['type ' ] === Router::TYPE_SINGLE ) {
306- return $ this ->runCommand ($ info[ ' name ' ], $ info [ ' handler ' ] , $ cmdOptions , $ args );
306+ return $ this ->runCommand ($ info , $ cmdOptions , $ args );
307307 }
308308
309309 // is controller/group
@@ -313,16 +313,18 @@ public function dispatch(string $name, array $args = [])
313313 /**
314314 * run a independent command
315315 *
316- * @param string $name Command name
317- * @param Closure|string $handler Command class or handler func
316+ * @param array{name: string, handler: mixed, realName: string} $info
318317 * @param array $options
319318 * @param array $args
320319 *
321320 * @return mixed
322321 * @throws Throwable
323322 */
324- protected function runCommand (string $ name , $ handler , array $ options , array $ args )
323+ protected function runCommand (array $ info , array $ options , array $ args )
325324 {
325+ /** @var Closure|string $handler Command class or handler func */
326+ $ handler = $ info ['handler ' ];
327+
326328 if (is_object ($ handler ) && method_exists ($ handler , '__invoke ' )) {
327329 $ fs = SFlags::new ();
328330 $ fs ->addOptsByRules (GlobalOption::getAloneOptions ());
@@ -344,13 +346,13 @@ protected function runCommand(string $name, $handler, array $options, array $arg
344346
345347 /** @var Command $object */
346348 $ object = new $ handler ($ this ->input , $ this ->output );
347-
348349 if (!($ object instanceof Command)) {
349350 Helper::throwInvalidArgument ("The console command class [ $ handler] must instanceof the " . Command::class);
350351 }
351352
352- $ object ::setName ($ name );
353+ $ object ::setName ($ info [ ' cmdId ' ]); // real command name.
353354 $ object ->setApp ($ this );
355+ $ object ->setCommandName ($ info ['name ' ]);
354356 $ result = $ object ->run ($ args );
355357 }
356358
@@ -380,8 +382,8 @@ protected function runAction(array $info, array $options, array $args, bool $det
380382 $ controller ->setDetached ();
381383 }
382384
383- if ($ info ['action ' ]) {
384- array_unshift ($ args , $ info ['action ' ]);
385+ if ($ info ['sub ' ]) {
386+ array_unshift ($ args , $ info ['sub ' ]);
385387 }
386388
387389 // Command method, no suffix
@@ -441,6 +443,12 @@ protected function createController(array $info): Controller
441443 // force set name and description
442444 $ handler ::setName ($ group );
443445 $ handler ->setApp ($ this );
446+
447+ // set input name
448+ if ($ inputName = $ info ['name ' ] ?? '' ) {
449+ $ handler ->setGroupName ($ inputName );
450+ }
451+
444452 $ handler ->setDelimiter ($ this ->delimiter );
445453
446454 // cache object
0 commit comments