1010
1111use Inhere \Console \IO \Input ;
1212use Inhere \Console \IO \Output ;
13- use Inhere \Console \Traits \InputOutputTrait ;
13+ use Inhere \Console \Traits \InputOutputAwareTrait ;
1414use Inhere \Console \Traits \SimpleEventTrait ;
1515use Inhere \Console \Style \Style ;
16+ use Inhere \Console \Utils \FormatUtil ;
1617use Inhere \Console \Utils \Helper ;
1718
1819/**
2122 */
2223abstract class AbstractApplication implements ApplicationInterface
2324{
24- use InputOutputTrait , SimpleEventTrait;
25+ use InputOutputAwareTrait , SimpleEventTrait;
2526
2627 /**
2728 * @var array
@@ -183,7 +184,7 @@ protected function afterRun()
183184 if ($ this ->isProfile ()) {
184185 $ title = '---------- Runtime Stats(profile=true) ---------- ' ;
185186 $ stats = $ this ->meta ['_stats ' ];
186- $ this ->meta ['_stats ' ] = Helper ::runtime ($ stats ['startTime ' ], $ stats ['startMemory ' ], $ stats );
187+ $ this ->meta ['_stats ' ] = FormatUtil ::runtime ($ stats ['startTime ' ], $ stats ['startMemory ' ], $ stats );
187188 $ this ->output ->write ('' );
188189 $ this ->output ->aList ($ this ->meta ['_stats ' ], $ title );
189190 }
@@ -409,6 +410,7 @@ public function showCommandList($quit = true)
409410 $ commands = $ this ->commands ;
410411 $ commandArr [] = PHP_EOL . '- <cyan>Independent Commands</cyan> ' ;
411412 ksort ($ commands );
413+
412414 foreach ($ commands as $ name => $ command ) {
413415 $ desc = $ desPlaceholder ;
414416 $ hasCommand = true ;
@@ -434,26 +436,18 @@ public function showCommandList($quit = true)
434436 // built in commands
435437 $ internalCommands = static ::$ internalCommands ;
436438 ksort ($ internalCommands );
437- array_unshift ($ internalCommands , "\n- <cyan>Internal Commands</cyan> " );
439+ // array_unshift($internalCommands, "\n- <cyan>Internal Commands</cyan>");
440+
441+ // built in options
442+ $ internalOptions = FormatUtil::commandOptions (self ::$ internalOptions );
438443
439444 $ this ->output ->mList ([
440- //'There are all console controllers and independent commands.',
441445 'Usage: ' => "$ script {command} [arg0 arg1=value1 arg2=value2 ...] [--opt -v -h ...] " ,
442- 'Options: ' => self ::$ internalOptions ,
443- 'Available Commands: ' => array_merge ($ controllerArr , $ commandArr , $ internalCommands ),
444- //'Independent Commands:' => $commandArr ?: '... No register any independent command',
445- // 'Internal Commands:' => $internalCommands,
446+ 'Options: ' => $ internalOptions ,
447+ 'Internal Commands: ' => $ internalCommands ,
448+ 'Available Commands: ' => array_merge ($ controllerArr , $ commandArr ),
446449 ]);
447450
448- // $this->output->mList([
449- // //'There are all console controllers and independent commands.',
450- // 'Usage:' => "$script {command} [arg0 arg1=value1 arg2=value2 ...] [--opt -v -h ...]",
451- // 'Options:' => self::$internalOptions,
452- // 'Group Commands:' => $controllerArr ?: '... No register any group command(controller)',
453- // 'Independent Commands:' => $commandArr ?: '... No register any independent command',
454- // 'Internal Commands:' => $internalCommands,
455- // ]);
456-
457451 unset($ controllerArr , $ commandArr , $ internalCommands );
458452 $ this ->output ->write ("More command information, please use: <cyan> $ script {command} -h</cyan> " );
459453
@@ -535,6 +529,7 @@ public function getCommandNames()
535529
536530 /**
537531 * @param array $controllers
532+ * @throws \InvalidArgumentException
538533 */
539534 public function setControllers (array $ controllers )
540535 {
@@ -566,6 +561,7 @@ public function isController($name)
566561
567562 /**
568563 * @param array $commands
564+ * @throws \InvalidArgumentException
569565 */
570566 public function setCommands (array $ commands )
571567 {
0 commit comments