3232/**
3333 * Print out command list
3434 */
35- class HelpCommand extends BaseCommand implements CommandCollectionAwareInterface
35+ class HelpCommand extends BaseCommand implements CommandCollectionAwareInterface, CommandHiddenInterface
3636{
3737 /**
3838 * The command collection to get help on.
@@ -41,6 +41,13 @@ class HelpCommand extends BaseCommand implements CommandCollectionAwareInterface
4141 */
4242 protected CommandCollection $ commands ;
4343
44+ /**
45+ * The header line rendered above command listings.
46+ *
47+ * @var string|null
48+ */
49+ protected ?string $ headerLine = null ;
50+
4451 /**
4552 * @inheritDoc
4653 */
@@ -49,6 +56,17 @@ public function setCommandCollection(CommandCollection $commands): void
4956 $ this ->commands = $ commands ;
5057 }
5158
59+ /**
60+ * Set the header line rendered above command listings.
61+ *
62+ * @param string $headerLine Header text including optional console markup.
63+ * @return void
64+ */
65+ public function setHeaderLine (string $ headerLine ): void
66+ {
67+ $ this ->headerLine = $ headerLine ;
68+ }
69+
5270 /**
5371 * Main function Prints out the list of commands.
5472 *
@@ -139,10 +157,12 @@ protected function asText(ConsoleIoInterface $io, iterable $commands, bool $verb
139157 }
140158 sort ($ commandList );
141159
160+ $ headerLine = $ this ->getHeaderLine ();
161+ if ($ headerLine !== '' ) {
162+ $ io ->out ($ headerLine , 2 );
163+ }
164+
142165 if ($ verbose ) {
143- $ version = Configure::version ();
144- $ debug = Configure::read ('debug ' ) ? 'true ' : 'false ' ;
145- $ io ->out ("<info>CakePHP:</info> {$ version } (debug: {$ debug }) " , 2 );
146166 $ this ->outputPaths ($ io );
147167 $ this ->outputGrouped ($ io , $ invert );
148168 } else {
@@ -160,6 +180,27 @@ protected function asText(ConsoleIoInterface $io, iterable $commands, bool $verb
160180 }
161181 }
162182
183+ /**
184+ * Get the help output header line.
185+ *
186+ * @return string
187+ */
188+ protected function getHeaderLine (): string
189+ {
190+ if ($ this ->headerLine !== null ) {
191+ return $ this ->headerLine ;
192+ }
193+
194+ $ version = Configure::version ();
195+ if ($ version === 'unknown ' ) {
196+ return '' ;
197+ }
198+
199+ $ debug = Configure::read ('debug ' ) ? 'true ' : 'false ' ;
200+
201+ return "<info>CakePHP:</info> {$ version } (debug: {$ debug }) " ;
202+ }
203+
163204 /**
164205 * Output commands grouped by plugin/namespace (verbose mode).
165206 *
@@ -208,7 +249,7 @@ protected function outputGrouped(ConsoleIoInterface $io, array $invert): void
208249 $ io ->out ("<info> {$ prefix }</info>: " );
209250 sort ($ names );
210251 foreach ($ names as $ data ) {
211- $ io ->out (' - ' . $ data ['name ' ]);
252+ $ io ->out (' - <comment> ' . $ data ['name ' ] . ' </comment> ' );
212253 if ($ data ['description ' ]) {
213254 $ io ->info (str_pad (" \u{2514}" , 13 , "\u{2500}" ) . ' ' . $ data ['description ' ]);
214255 }
@@ -259,7 +300,7 @@ protected function outputCompactCommands(ConsoleIoInterface $io, array $commands
259300 foreach ($ commands as $ data ) {
260301 $ maxNameLength = max ($ maxNameLength , strlen ($ data ['name ' ]));
261302 }
262- $ nameColumnWidth = $ maxNameLength + 3 ;
303+ $ nameColumnWidth = max ( $ maxNameLength + 5 , 17 ) ;
263304
264305 // Output single commands under "Available Commands:" header
265306 $ isFirst = true ;
@@ -268,7 +309,7 @@ protected function outputCompactCommands(ConsoleIoInterface $io, array $commands
268309 foreach ($ singleCommands as $ prefix => $ cmd ) {
269310 $ description = $ cmd ['description ' ];
270311 $ padding = str_repeat (' ' , $ nameColumnWidth - 2 - strlen ($ prefix ));
271- $ linePrefix = ' <info > ' . $ prefix . '</info > ' . $ padding ;
312+ $ linePrefix = ' <comment > ' . $ prefix . '</comment > ' . $ padding ;
272313
273314 if ($ description !== '' ) {
274315 $ description = strtok ($ description , "\n" );
@@ -292,7 +333,7 @@ protected function outputCompactCommands(ConsoleIoInterface $io, array $commands
292333 $ description = $ cmd ['description ' ];
293334
294335 $ padding = str_repeat (' ' , $ nameColumnWidth - 2 - strlen ($ fullName ));
295- $ linePrefix = ' <info > ' . $ fullName . '</info > ' . $ padding ;
336+ $ linePrefix = ' <comment > ' . $ fullName . '</comment > ' . $ padding ;
296337
297338 if ($ description !== '' ) {
298339 $ description = strtok ($ description , "\n" );
0 commit comments