From 797ee4e175c90a51ef4c9ea25db6195974b13a72 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 30 Sep 2023 20:56:28 +0100 Subject: [PATCH] [php] --version ``` $ ./build.sh && ./rosettaboy-release --version 2>/dev/null 8.2.10 ``` --- php/src/args.php | 10 ++++++++-- php/src/main.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/php/src/args.php b/php/src/args.php index 2127e77..17ab539 100644 --- a/php/src/args.php +++ b/php/src/args.php @@ -13,6 +13,7 @@ final class Args 't' => 'turbo', 'f' => 'frames', 'p' => 'profile', + 'v' => 'version', ]; private const USAGE = << $opts */ - $opts = getopt("cgraHStf:p:h", ["debug-cpu", "debug-gpu", "debug-ram", "debug-apu", "headless", "silent", "turbo", "frames:", "profile:", "help"], $rest_index) ?: []; + $opts = getopt("cgraHStf:p:hv", ["debug-cpu", "debug-gpu", "debug-ram", "debug-apu", "headless", "silent", "turbo", "frames:", "profile:", "help", "version"], $rest_index) ?: []; $pos_args = array_slice($argv, $rest_index); $opts = array_combine( @@ -48,8 +50,12 @@ public static function parse(array $argv): self }, array_values($opts)) ); + if (isset($opts['version'])) { + echo phpversion() . "\n"; + exit(0); + } if (isset($opts['help']) || count($pos_args) === 0) { - echo self::USAGE; + echo self::USAGE . "\n"; exit(0); } diff --git a/php/src/main.php b/php/src/main.php index b5cbe54..34985e0 100755 --- a/php/src/main.php +++ b/php/src/main.php @@ -9,7 +9,7 @@ function exception_error_handler($errno, $errstr, $errfile, $errline) set_error_handler("exception_error_handler"); if (!function_exists("SDL_Init")) { - print("!!! WARNING !!!\nUsing fake SDL\n"); + fwrite(STDERR, "!!! WARNING !!!\nUsing fake SDL\n"); require "_sdl.php"; } require "args.php";