@@ -44,8 +44,16 @@ abstract class Controller extends AbstractCommand
4444 */
4545 public $ delimiter = '/ ' ; // '/' ':'
4646
47+ /**
48+ * @var bool
49+ */
4750 protected $ showMore = true ;
4851
52+ /**
53+ * @var bool
54+ */
55+ private $ standAlone = false ;
56+
4957 /**
5058 * load command configure
5159 */
@@ -104,13 +112,13 @@ protected function showHelp()
104112
105113 /**
106114 * Show help of the controller command group or specified command action
107- * @usage <info>{name}/[command] -h</info> OR <info>{name}/help [command]</info> OR <info>{name} [command]</info>
115+ * @usage <info>{name}/[command] -h</info> OR <info>{command} [command]</info> OR <info>{name} [command] -h </info>
108116 * @example
109- * {script} {name} -h
110- * {script} {name}/help
111- * {script} {name}/help index
112- * {script} {name}/index -h
113- * {script} {name} index
117+ * {script} {name} -h
118+ * {script} {name}/help
119+ * {script} {name}/help index
120+ * {script} {name}/index -h
121+ * {script} {name} index
114122 *
115123 * @return int
116124 */
@@ -135,13 +143,12 @@ final public function helpCommand()
135143 final protected function showCommandList ()
136144 {
137145 $ ref = new \ReflectionClass ($ this );
138-
139- $ class = $ ref ->getName ();
140146 $ sName = lcfirst (self ::getName () ?: $ ref ->getShortName ());
141- $ this ->write ("This is in the console controller [<bold> $ class</bold>] \n" );
147+
148+ // $this->write(sprintf("This is in the console controller [<bold>%s</bold>]\n", $class = $ref->getName();));
142149
143150 if (!($ classDes = self ::getDescription ())) {
144- $ classDes = Annotation::description ($ ref ->getDocComment ()) ?: 'No Description ' ;
151+ $ classDes = Annotation::description ($ ref ->getDocComment ()) ?: 'No Description for the console controller ' ;
145152 }
146153
147154 $ suffix = $ this ->actionSuffix ;
@@ -172,16 +179,22 @@ final protected function showCommandList()
172179 }
173180 }
174181
175- $ sep = $ this ->delimiter ;
176- $ name = $ sName . $ sep ;
182+ if ($ this ->standAlone ) {
183+ $ name = $ sName . ' ' ;
184+ $ usage = '<info>{command}</info> [arguments] [options] ' ;
185+ } else {
186+ $ name = $ sName . $ this ->delimiter ;
187+ $ usage = "<info> {$ name }</info>{command} [arguments] [options] " ;
188+ }
189+
177190 $ this ->output ->mList ([
178191 'Description: ' => $ classDes ,
179- 'Usage: ' => "{ $ name } [command] [arguments] [options] " ,
180- 'Group Name: ' => "<info> $ sName</info> " ,
192+ 'Usage: ' => $ usage ,
193+ // 'Group Name:' => "<info>$sName</info>",
181194 'Commands: ' => $ commands ,
182195 'Options: ' => [
183- '--help,-h ' => 'Show help of the command group or specified command action ' ,
184- $ this ->showMore ? "\nMore information please use <cyan> {$ name }[command] -h</cyan> OR <cyan> { $ name } help [command]</cyan> " : ''
196+ '-h,--help ' => 'Show help of the command group or specified command action ' ,
197+ $ this ->showMore ? "\nMore information please use <cyan> {$ name }[command] -h</cyan> " : ''
185198 ],
186199 ]);
187200 }
@@ -254,4 +267,21 @@ public function setNotFoundCallback($notFoundCallback)
254267 {
255268 $ this ->notFoundCallback = $ notFoundCallback ;
256269 }
270+
271+ /**
272+ * @return bool
273+ */
274+ public function isStandAlone (): bool
275+ {
276+ return $ this ->standAlone ;
277+ }
278+
279+ /**
280+ * @param bool $standAlone
281+ */
282+ public function setStandAlone ($ standAlone = true )
283+ {
284+ $ this ->standAlone = (bool )$ standAlone ;
285+ }
286+
257287}
0 commit comments