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.
This PR introduces a non-interactive mode for Prompts.
When Prompts are non-interactive, they will attempt to return the configured default value instead of prompting. Most prompts have a safe default when none is provided. An exception will be thrown if the default value does not pass any validation checks.
This is useful when prompts occur in a non-interactive environment, such as a scheduled task, queued job, CI, or deploy script.
The behaviour is currently mixed, depending on the scenario. #63 prevented prompts from waiting indefinitely for input when the fallback was not triggered, but everything now depends on the fallback to handle non-interactive mode. When using a Symfony fallback, there are some inconsistencies. For example, the
choice
component doesn't allow you to select nothing in interactive mode but will returnnull
in non-interactive mode. With this PR, the fallbacks no longer need to be used for non-interactive mode - just for Windows and when testing (for now).This is a breaking change because Laravel depends on the fallback when running tests and the non-interactive mode will take over in a CI testing environment. If we release this change inEdit: We can release this asv0.2
, Laravel can update its version constraint and ensure interactive mode is enabled when testing. The companion PR is at laravel/framework#484680.1.9
and update the minimum version in the framework. This will avoid conflicts for users that have other packages that currently depend on^0.1
.In the future, I would like to prevent the need for fallbacks when testing so that fallback mode is only required for Windows environments (and maybe that can even be solved with #17).
This also paves the way for #57, which needs to know when Laravel commands are explicitly told to be non-interactive (via the
-n
argument), regardless of the presence of a tty.Fixes #64