Skip to content

Commit

Permalink
[php] --version
Browse files Browse the repository at this point in the history
```
$ ./build.sh && ./rosettaboy-release --version 2>/dev/null
8.2.10
```
  • Loading branch information
shish committed Sep 30, 2023
1 parent 7a6cfef commit 797ee4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions php/src/args.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class Args
't' => 'turbo',
'f' => 'frames',
'p' => 'profile',
'v' => 'version',
];

private const USAGE = <<<EOF
Expand All @@ -30,13 +31,14 @@ final class Args
-f, --frames=FRAMES Exit after N frames
-p, --profile=PROFILE Exit after N seconds
-t, --turbo No sleep between frames
-v, --version Show build info
EOF;

public static function parse(array $argv): self
{
$rest_index = null;
/** @var array<string, mixed> $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(
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion php/src/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 797ee4e

Please sign in to comment.