@@ -64,9 +64,6 @@ abstract class AbstractHandler implements CommandHandlerInterface
6464 /** @var Application */
6565 protected $ app ;
6666
67- /** @var array common options for all sub-commands */
68- private $ commonOptions ;
69-
7067 /** @var InputDefinition|null */
7168 private $ definition ;
7269
@@ -110,7 +107,6 @@ public function __construct(Input $input, Output $output, InputDefinition $defin
110107 $ this ->definition = $ definition ;
111108 }
112109
113- $ this ->commonOptions = $ this ->commonOptions ();
114110 $ this ->commentsVars = $ this ->annotationVars ();
115111
116112 $ this ->init ();
@@ -142,17 +138,6 @@ protected function createDefinition(): InputDefinition
142138 return $ this ->definition ;
143139 }
144140
145- /**
146- * you can set common options for all sub-commands
147- * @return array
148- */
149- protected function commonOptions (): array
150- {
151- return [
152- '--skip-invalid ' => 'Whether ignore invalid arguments and options, when use input definition ' ,
153- ];
154- }
155-
156141 /**
157142 * Provides parsable substitution variables for command annotations. Can be used in comments in commands
158143 * 为命令注解提供可解析的替换变量. 可以在命令的注释中使用
@@ -574,9 +559,11 @@ protected function showHelpByMethodAnnotations(string $method, string $action =
574559 unset($ help ['Description: ' ]);
575560 }
576561
577- $ help ['Global Options: ' ] = FormatUtil::alignOptions (
578- \array_merge (Application::getGlobalOptions (), $ this ->commonOptions )
579- );
562+ $ help ['Group Options: ' ] = null ;
563+ $ help ['Global Options: ' ] = FormatUtil::alignOptions (Application::getGlobalOptions ());
564+
565+ $ this ->beforeRenderCommandHelp ($ help );
566+
580567 $ this ->output ->mList ($ help , [
581568 'sepChar ' => ' ' ,
582569 'lastNewline ' => 0 ,
@@ -585,6 +572,10 @@ protected function showHelpByMethodAnnotations(string $method, string $action =
585572 return 0 ;
586573 }
587574
575+ protected function beforeRenderCommandHelp (array &$ help ): void
576+ {
577+ }
578+
588579 /**************************************************************************
589580 * getter/setter methods
590581 **************************************************************************/
@@ -707,14 +698,6 @@ public function setDefinition(InputDefinition $definition): void
707698 $ this ->definition = $ definition ;
708699 }
709700
710- /**
711- * @return array
712- */
713- public function getCommonOptions (): array
714- {
715- return $ this ->commonOptions ;
716- }
717-
718701 /**
719702 * @return array
720703 */
0 commit comments