@@ -257,7 +257,7 @@ protected function getFileFilter(): callable
257257 * @throws ReflectionException
258258 * @throws InvalidArgumentException
259259 */
260- public function dispatch (string $ name , bool $ standAlone = false )
260+ public function dispatch (string $ name , bool $ detachedRun = false )
261261 {
262262 $ this ->logf (Console::VERB_DEBUG , 'begin dispatch command: %s ' , $ name );
263263
@@ -287,23 +287,25 @@ public function dispatch(string $name, bool $standAlone = false)
287287 return 2 ;
288288 }
289289
290+ $ cmdOptions = $ info ['options ' ];
291+
290292 // save command ID
291293 $ this ->input ->setCommandId ($ info ['cmdId ' ]);
292294
293295 // is command
294296 if ($ info ['type ' ] === Router::TYPE_SINGLE ) {
295- return $ this ->runCommand ($ info ['name ' ], $ info ['handler ' ], $ info [ ' options ' ] );
297+ return $ this ->runCommand ($ info ['name ' ], $ info ['handler ' ], $ cmdOptions );
296298 }
297299
298300 // is controller/group
299- return $ this ->runAction ($ info ['group ' ], $ info ['action ' ], $ info ['handler ' ], $ info [ ' options ' ] , $ standAlone );
301+ return $ this ->runAction ($ info ['group ' ], $ info ['action ' ], $ info ['handler ' ], $ cmdOptions , $ detachedRun );
300302 }
301303
302304 /**
303305 * run a independent command
304306 *
305307 * @param string $name Command name
306- * @param Closure|string $handler Command class
308+ * @param Closure|string $handler Command class or handler func
307309 * @param array $options
308310 *
309311 * @return mixed
@@ -346,12 +348,12 @@ protected function runCommand(string $name, $handler, array $options)
346348 * @param string $action Command method, no suffix
347349 * @param mixed $handler The controller class or object
348350 * @param array $options
349- * @param bool $standAlone
351+ * @param bool $detachedRun
350352 *
351353 * @return mixed
352354 * @throws ReflectionException
353355 */
354- protected function runAction (string $ group , string $ action , $ handler , array $ options , bool $ standAlone = false )
356+ protected function runAction (string $ group , string $ action , $ handler , array $ options , bool $ detachedRun = false )
355357 {
356358 /** @var Controller $handler */
357359 if (is_string ($ handler )) {
@@ -372,15 +374,18 @@ protected function runAction(string $group, string $action, $handler, array $opt
372374 );
373375 }
374376
377+ // force set name and description
375378 $ handler ::setName ($ group );
376-
377379 if ($ desc = $ options ['description ' ] ?? '' ) {
378380 $ handler ::setDescription ($ desc );
379381 }
380382
381383 $ handler ->setApp ($ this );
382384 $ handler ->setDelimiter ($ this ->delimiter );
383- $ handler ->setExecutionAlone ($ standAlone );
385+
386+ if ($ detachedRun ) {
387+ $ handler ->setDetached ();
388+ }
384389
385390 return $ handler ->run ($ action );
386391 }
0 commit comments