-
Notifications
You must be signed in to change notification settings - Fork 6
/
sb
executable file
·37 lines (33 loc) · 874 Bytes
/
sb
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
#!/usr/bin/php -Cq
<?php
namespace Starbug\Core;
// Remove this file and script name
array_shift($argv);
$script = array_shift($argv);
// Split remaining arguments into positional and named.
$positional = [];
$named = [];
foreach ($argv as $i => $arg) {
if (0 === strpos($arg, "-")) {
$arg = ltrim($arg, "-");
$parts = (false !== strpos($arg, "=")) ? explode("=", $arg, 2) : [$arg, true];
$named[$parts[0]] = $parts[1];
} else {
$positional[] = $arg;
}
}
// Bootstrap application container.
$args = $named;
chdir(dirname(__FILE__));
if (!empty($args["t"])) {
include("vendor/starbug/di/bootstrap/test.php");
} else {
include("vendor/starbug/di/bootstrap/default.php");
}
// Execute script
$className = $container->get("scripts.".$script);
$container->call($className, [
"argv" => $argv,
"positional" => $positional,
"named" => $named
]);