From f42073c186a3eedbf4d6b4b63f33bfdbdbee1864 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Tue, 24 Nov 2026 03:12:46 +0100 Subject: [PATCH 1/2] Document --no-interaction and ConsoleIo::isInteractive() --- docs/en/appendices/5-5-migration-guide.md | 19 +++++++++++++++++++ docs/en/console-commands/input-output.md | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/docs/en/appendices/5-5-migration-guide.md b/docs/en/appendices/5-5-migration-guide.md index 132f91a59f..170f312cb9 100644 --- a/docs/en/appendices/5-5-migration-guide.md +++ b/docs/en/appendices/5-5-migration-guide.md @@ -43,6 +43,15 @@ bin/cake upgrade rector --rules cakephp55 `BadRequestException` (HTTP 400). See [HTTP Method Overrides](../controllers/request-response#http-method-overrides). +### Console + +- `--quiet` now also skips options defined with `prompt`. Previously these + were asked while arguments were parsed, before `--quiet` took effect. A + required option left without a value now fails with the usual missing option + error instead of waiting for input. +- Commands are switched to non-interactive mode before `initialize()` runs, so + prompts in `initialize()` respect `--quiet` and `--no-interaction` too. + ## Deprecations ### Database @@ -65,6 +74,16 @@ bin/cake upgrade rector --rules cakephp55 the path expression is used if not set. - `FunctionsBuilder::jsonExists()` was added. +### Console + +- `ConsoleIo::isInteractive()` was added. +- `--no-interaction` was added to the default command options. It disables + prompts, which answer with their default value, while keeping the normal + output level. Unlike `--quiet` it does not hide output. If your application + already defines a `no-interaction` option, you can remove it, or keep it: + your definition replaces the default one, and CakePHP now switches the + command to non-interactive mode when it is passed. + ### TestSuite - `Cake\TestSuite\Fixture\DeleteStrategy` was added. This fixture strategy diff --git a/docs/en/console-commands/input-output.md b/docs/en/console-commands/input-output.md index e70f28ceff..af71999789 100644 --- a/docs/en/console-commands/input-output.md +++ b/docs/en/console-commands/input-output.md @@ -278,6 +278,20 @@ $selection = $io->askChoice('Red or Green?', ['R', 'G'], 'R'); Selection validation is case-insensitive. +When a command runs with `--quiet` or `--no-interaction`, prompts are not +shown and `ask()` and `askChoice()` return their default value. Use +`$io->isInteractive()` to check whether prompts are enabled, for example to +skip a confirmation step. Options defined with `prompt` are not asked either; +a required option without a value then fails with a missing option error. + +```text +bin/cake my_command --no-interaction +``` + +::: info Added in version 5.5.0 +`ConsoleIo::isInteractive()` and the `--no-interaction` option were added. +::: + ## Creating Files `method` Cake\\Console\\ConsoleIo::**createFile**(string $path, string $contents, bool $forceOverwrite = false): bool @@ -409,6 +423,9 @@ You can control the output level of commands, by using the `--quiet` and `--verbose` options. These options are added by default, and allow you to consistently control output levels inside your CakePHP commands. +`--quiet` also disables interactive prompts. To disable prompts but keep the +normal output, use `--no-interaction` instead. + The `--quiet` and `--verbose` options also control how logging data is output to stdout/stderr. Normally info and higher log messages are output to stdout/stderr. When `--verbose` is used, debug logs will be output to stdout. From 17580203137eaf815b99bf46e3519edf59697487 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Wed, 25 Nov 2026 18:29:14 +0100 Subject: [PATCH 2/2] Update docs/en/appendices/5-5-migration-guide.md Co-authored-by: Mark Story --- docs/en/appendices/5-5-migration-guide.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/en/appendices/5-5-migration-guide.md b/docs/en/appendices/5-5-migration-guide.md index 170f312cb9..11ab2e823a 100644 --- a/docs/en/appendices/5-5-migration-guide.md +++ b/docs/en/appendices/5-5-migration-guide.md @@ -80,9 +80,8 @@ bin/cake upgrade rector --rules cakephp55 - `--no-interaction` was added to the default command options. It disables prompts, which answer with their default value, while keeping the normal output level. Unlike `--quiet` it does not hide output. If your application - already defines a `no-interaction` option, you can remove it, or keep it: - your definition replaces the default one, and CakePHP now switches the - command to non-interactive mode when it is passed. + already defines a `no-interaction` option, you can remove it, or keep it. + The option definition in your application replaces the default one. ### TestSuite