From e34616d7b409913abc1448c673ece0ddd815a23e Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 10 Oct 2025 12:14:59 +0200 Subject: [PATCH 1/2] Add docs for cakephp/cakephp#18958 --- en/appendices/5-3-migration-guide.rst | 2 ++ en/console-commands/commands.rst | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/en/appendices/5-3-migration-guide.rst b/en/appendices/5-3-migration-guide.rst index 25dba3c845..8598a8039b 100644 --- a/en/appendices/5-3-migration-guide.rst +++ b/en/appendices/5-3-migration-guide.rst @@ -92,6 +92,8 @@ Console - Added ``TreeHelper`` which outputs an array as a tree such as an array of filesystem directories as array keys and files as lists under each directory. +- Commands can now implement ``getGroup()`` to customize how commands are + grouped in ``bin/cake -h`` output. Core ---- diff --git a/en/console-commands/commands.rst b/en/console-commands/commands.rst index 797c69a337..8d840701b0 100644 --- a/en/console-commands/commands.rst +++ b/en/console-commands/commands.rst @@ -289,6 +289,21 @@ As well as in the help section of your command: Usage: cake user [-h] [-q] [-v] +Grouping Commands +================= + +By default in the help output CakePHP will group commands into core, app, and +plugin groups. You can customize the grouping of commands by implementing +``getGroup()``: + + public static function getGroup(): string + { + return 'maintenance'; + } + +.. versionadded:: 5.3.0 + Custom grouping support was added. + .. _console-integration-testing: Testing Commands From dd842bb1d94c14483405751873a7bf47b709c0db Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 10 Oct 2025 12:18:23 +0200 Subject: [PATCH 2/2] Expand example --- en/console-commands/commands.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/en/console-commands/commands.rst b/en/console-commands/commands.rst index 8d840701b0..07a30ca735 100644 --- a/en/console-commands/commands.rst +++ b/en/console-commands/commands.rst @@ -296,9 +296,12 @@ By default in the help output CakePHP will group commands into core, app, and plugin groups. You can customize the grouping of commands by implementing ``getGroup()``: - public static function getGroup(): string + class CleanupCommand extends Command { - return 'maintenance'; + public static function getGroup(): string + { + return 'maintenance'; + } } .. versionadded:: 5.3.0