confirm method
//////////////////// Confirmation Messages Guidelines
Prompts the user for a y/n confirmation.
Accepts an optional defaultValue to specify what happens when the user simply presses Enter.
Returns true for "yes" or "y" and false for "no" or "n".
Format:
<message prompt> [y/n]:
Throws UserInputRequiredException in --non-interactive mode, unless
--yes answers the prompt.
Implementation
// User input
/// ***Confirmation Messages Guidelines***
///
/// Prompts the user for a `y/n` confirmation.
/// Accepts an optional [defaultValue] to specify what happens when the user simply presses Enter.
/// Returns `true` for "yes" or "y" and `false` for "no" or "n".
///
/// Format:
/// ```bash
/// <message prompt> [y/n]:
/// ```
///
/// Throws [UserInputRequiredException] in `--non-interactive` mode, unless
/// `--yes` answers the prompt.
Future<bool> confirm(String message, {bool? defaultValue}) async {
if (configuration?.skipConfirmation == true) {
info('$message: y');
return true;
}
if (configuration?.nonInteractive == true) {
throw UserInputRequiredException.confirmation(message);
}
return promptConfirm(message, defaultValue: defaultValue);
}