1515use Inhere \Console \Traits \InputOutputAwareTrait ;
1616use Inhere \Console \Traits \UserInteractAwareTrait ;
1717use Inhere \Console \Utils \Annotation ;
18+ use Inhere \Console \Utils \FormatUtil ;
1819
1920/**
2021 * Class AbstractCommand
@@ -413,7 +414,7 @@ protected function showHelpByMethodAnnotations($method, $action = null, array $a
413414 $ help = [];
414415
415416 if ($ aliases ) {
416- $ help [] = sprintf ( " <comment> Alias Name:</comment> %s \n" , implode (', ' , $ aliases) );
417+ $ help [' Alias Name: ' ] = implode (', ' , $ aliases );
417418 }
418419
419420 foreach (array_keys (self ::$ annotationTags ) as $ tag ) {
@@ -429,10 +430,21 @@ protected function showHelpByMethodAnnotations($method, $action = null, array $a
429430 $ msg = self ::getDescription ();
430431 }
431432
432- $ help [] = " <comment> $ tag :</comment> \n $ msg\n" ;
433+ $ help [$ tag . ' : ' ] = $ msg ;
433434 }
434435
435- $ this ->output ->write (implode ("\n" , $ help ), false );
436+ if (isset ($ help ['Description: ' ])) {
437+ $ description = $ help ['Description: ' ] ?: 'No description message for the command ' ;
438+ $ this ->write (ucfirst ($ description ) . PHP_EOL );
439+ unset($ help ['Description: ' ]);
440+ }
441+
442+ $ help ['Global Options: ' ] = FormatUtil::alignmentOptions (Application::getInternalOptions ());
443+
444+ $ this ->output ->mList ($ help , [
445+ 'sepChar ' => ' ' ,
446+ 'lastNewline ' => 0 ,
447+ ]);
436448
437449 return 0 ;
438450 }
@@ -525,17 +537,17 @@ public function getAnnotationVars(): array
525537 }
526538
527539 /**
528- * @return ApplicationInterface
540+ * @return AbstractApplication
529541 */
530- public function getApp (): ApplicationInterface
542+ public function getApp (): AbstractApplication
531543 {
532544 return $ this ->app ;
533545 }
534546
535547 /**
536- * @param ApplicationInterface $app
548+ * @param AbstractApplication $app
537549 */
538- public function setApp (ApplicationInterface $ app )
550+ public function setApp (AbstractApplication $ app )
539551 {
540552 $ this ->app = $ app ;
541553 }
0 commit comments