Repository navigation
Add ConsoleIo::isInteractive() and --no-interaction option - #19821
Open
dereuromark wants to merge 1 commit into
Open
dereuromark wants to merge 1 commit into
dereuromark wants to merge 1 commit into
Conversation
--quiet both lowers the output level and disables prompts. There was no way to run a command non-interactively with normal output, and no getter for the interactive state, so commands checked the output level instead. --no-interaction is a long-only default option (-n is used by plugins) that disables prompts without changing the output level. The interactive state is now set before initialize(), so prompts there respect it too.
LordSimal
approved these changes
Nov 20, 2026
dereuromark
marked this pull request as ready for review
November 20, 2026 17:42
josbeir
reviewed
Nov 21, 2026
|
|
||
| $this->setOutputLevel($args, $io); | ||
| if ($args->getOption('quiet') || $args->getOption('no-interaction')) { | ||
| $io->setInteractive(false); |
Contributor
There was a problem hiding this comment.
🤖 --no-interaction is applied after ConsoleOptionParser::parse() has already asked any questions defined with prompt, so commands can still wait for input and hang in automation. Could we apply it inside the parser, after reading the arguments but before prompting, and report missing required input as an error? That should avoid needing a separate argv pre-scan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--quietdoes two things: it lowers the output level and turns prompts off (setInteractive(false), soask()/askChoice()return their defaults). You can't get one without the other. There is also no getter for the interactive state, so commands that want to skip a confirmation check the output level instead. cakephp/migrationsSeedCommanddoes$io->level() > ConsoleIo::QUIET.This adds:
ConsoleIo::isInteractive(): bool--no-interaction, a default option that disables prompts but leaves output at the normal level. It is long-only because-nis already taken by plugins (bakefixture -n, cakephp-setupdb_backup create -n). A command that defines its ownno-interactionoption still overrides it, sinceaddOption()replaces same-named options.--quietkeeps its current behavior. The interactive flag is now set beforeinitialize(), not after it, so a prompt ininitialize()respects--quietand--no-interactiontoo.Not covered: options declared with
'prompt' => ...are asked while argv is parsed, before any flag is applied, so neither--quietnor--no-interactionsuppresses them. That is how it works today and would need argv pre-scanning; I left it out.Open question for review: should core also get a
--yes/ConsoleIo::confirm()for "assume yes" confirmations? cakephp/migrations#1128 adds a command-level--yesfor now.Docs: cakephp/docs follow-up once the API is agreed.