#!/usr/bin/env php runCommand(arguments: $arguments); } catch (DependencyException|NotFoundException|Exception $e) { echo $e->getMessage() . PHP_EOL; exit(1); } function confirm(string $message = 'Are you sure? ', array $options = ['y', 'n'], string $default = 'n'): bool { // first $options means true, any other false echo $message, ' ('; $first = true; foreach ($options as $option) { // mark default if ($option === $default) { $option = strtoupper(string: $option); } if ($first) { echo $option; $first = false; } else { echo '/', $option; } } echo '): '; $handle = fopen(filename: "php://stdin", mode: 'r'); $line = trim(string: fgetc(stream: $handle)); fclose(stream: $handle); if ($line == '') { // enter $line = $default; } if ($line == $options[0]) { $result = true; } else { $result = false; } return $result; }