Skip to content

Commit 4a22c15

Browse files
committed
Validate options in test_old
Regularly try to use this one with --version instead of --php-version, which fails in a non-obvious way.
1 parent 514f710 commit 4a22c15

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

test_old/run.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ function showHelp($error) {
2626
);
2727
}
2828

29+
$allowedOptions = [
30+
'--no-progress' => true,
31+
'--verbose' => true,
32+
'--php-version' => true,
33+
];
34+
2935
$options = array();
3036
$arguments = array();
3137

@@ -35,7 +41,11 @@ function showHelp($error) {
3541
foreach ($argv as $arg) {
3642
if ('-' === $arg[0]) {
3743
$parts = explode('=', $arg);
38-
$options[$parts[0]] = $parts[1] ?? true;
44+
$name = $parts[0];
45+
if (!isset($allowedOptions[$name])) {
46+
showHelp("Unknown option \"$name\"");
47+
}
48+
$options[$name] = $parts[1] ?? true;
3949
} else {
4050
$arguments[] = $arg;
4151
}

0 commit comments

Comments
 (0)