-
Notifications
You must be signed in to change notification settings - Fork 0
/
radon.php
46 lines (38 loc) · 1.07 KB
/
radon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require 'includes/rn-settings.php';
function get_args(int $arg_number): string
{
$args = $_SERVER['argv'];
return $args[$arg_number];
}
function __help(): void
{
echo "Usage: php random.php [options] [arguments]\n";
echo "Options:\n";
echo " serve, -s, --serve\t\tStarting the development server\n";
echo " -h, --help\t\t\tShow this help message and exit\n";
echo " -v, --version\t\t\tShow program's version number and exit\n";
}
if (get_args(1) == 'serve' || get_args(1) == '-s' || get_args(1) == '--serve') {
// Start the server
echo 'Server started at ' . SITE_URL[0] . "\n";
try {
exec('php -S ' . SITE_URL[0]);
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
echo 'Server stopped.';
exit(0);
} else if (get_args(1) == '-h' || get_args(1) == '--help') {
// Show help
__help(get_args(1));
exit(0);
} else if (get_args(1) == '-v' || get_args(1) == '--version') {
// Show version
echo 'Radon ' . VERSION;
exit(0);
} else {
// Show help
__help();
exit(0);
}