promptYesNoSync function
Notice
This function blocks until a full line is available. If you do not want to block the current thread, use the async version instead.
See promptYesNo
Description
Prompt the user with question.
Returns true, if the user answered with yes and false if the user
answered with no.
Implementation
bool promptYesNoSync(
  String question, {
  bool defaultToYes = true,
}) {
  final options = defaultToYes ? "Y/n" : "y/N";
  stdout.writeln("$question [$options] ? ");
  final answer = stdin.readLineSync();
  if (null == answer) return defaultToYes;
  return switch (answer.toLowerCase().trim()) {
    "y" => true,
    "n" => false,
    _ => defaultToYes,
  };
}