@@ -280,27 +280,53 @@ protected function parseSignatureTokens(array $input)
280280
281281 protected function renderListView ()
282282 {
283- $ commandList = '' ;
283+ $ groups = [] ;
284284
285285 foreach ($ this ->config ['commands ' ] as $ commandName => $ command ) {
286- $ commandList .= " \033[1;32m $ commandName \033[0m — {$ command ['handler ' ]->getDescription ()}\n" ;
286+ $ parts = explode (': ' , $ commandName , 2 );
287+
288+ $ namespace = (count ($ parts ) === 2 ) ? $ parts [0 ] : '_global ' ;
289+
290+ $ groups [$ namespace ][$ commandName ] = $ command ['handler ' ]->getDescription ();
287291 }
288292
289- echo <<<HELP
293+ ksort ($ groups );
294+
295+ foreach ($ groups as $ namespace => &$ commands ) {
296+ ksort ($ commands );
297+ }
298+
299+ $ output = <<<HELP
290300{$ this ->config ['name ' ]} {$ this ->config ['version ' ]}
291301
292302Usage:
293303 command [options] [arguments]
294304
295305Options:
296- -h, --help - Display help for the given command.
297- -V, --version - Display this application version
306+ -h, --help Display help for the given command
307+ -V, --version Display this application version
298308
299309Available commands:
300- \033[1;32mlist \033[0m — List commands
301- $ commandList
302310
303311HELP ;
312+
313+ if (isset ($ groups ['_global ' ])) {
314+ foreach ($ groups ['_global ' ] as $ name => $ desc ) {
315+ $ output .= sprintf (" \033[1;32m%-18s \033[0m %s \n" , $ name , $ desc );
316+ }
317+
318+ unset($ groups ['_global ' ]);
319+ }
320+
321+ foreach ($ groups as $ namespace => $ commands ) {
322+ $ output .= " $ namespace \n" ;
323+
324+ foreach ($ commands as $ name => $ desc ) {
325+ $ output .= sprintf (" \033[1;32m%-18s \033[0m %s \n" , $ name , $ desc );
326+ }
327+ }
328+
329+ echo Style \Renderer::render ($ output );
304330 }
305331
306332 protected function renderHelpView (Command $ command )
0 commit comments