Browse Source

Merge pull request #17949 from cakephp/chore/commands-order

List App and CakePHP commands before plugin commands.
othercorey 1 year ago
parent
commit
fe7beeec0b
1 changed files with 11 additions and 4 deletions
  1. 11 4
      src/Console/Command/HelpCommand.php

+ 11 - 4
src/Console/Command/HelpCommand.php

@@ -119,6 +119,16 @@ class HelpCommand extends BaseCommand implements CommandCollectionAwareInterface
         }
         ksort($grouped);
 
+        if (isset($grouped['CakePHP'])) {
+            $cakephp = $grouped['CakePHP'];
+            $grouped = ['CakePHP' => $cakephp] + $grouped;
+        }
+
+        if (isset($grouped['App'])) {
+            $app = $grouped['App'];
+            $grouped = ['App' => $app] + $grouped;
+        }
+
         $this->outputPaths($io);
         $io->out('<info>Available Commands:</info>', 2);
 
@@ -172,13 +182,10 @@ class HelpCommand extends BaseCommand implements CommandCollectionAwareInterface
     /**
      * @param list<string> $names Names
      * @return string
+     * @psalm-param non-empty-list<string> $names
      */
     protected function getShortestName(array $names): string
     {
-        if (count($names) <= 1) {
-            return (string)array_shift($names);
-        }
-
         usort($names, function ($a, $b) {
             return strlen($a) - strlen($b);
         });