-
Notifications
You must be signed in to change notification settings - Fork 79
/
cli
executable file
·54 lines (39 loc) · 1.4 KB
/
cli
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
47
48
49
50
#!/usr/bin/env php
<?php
require_once 'vendor/autoload.php';
require_once 'includes/autoload.php';
chdir(__DIR__);
Localization::init();
//Keep display errors on, when in CLI
ini_set('display_errors', 'on');
error_reporting(E_ALL);
set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
if (!(error_reporting() & $errno)) {
return;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
Container::registerSingleton('DB', function () {
return new DB(new DateTimeZone(trim(file_get_contents('/etc/timezone'))));
});
date_default_timezone_set(trim(file_get_contents('/etc/timezone')));
Container::registerSingleton('Environment\Arguments', function () use ($argv) {
return new Environment\Arguments($argv);
});
if (!isset($argv)) {
return;
}
$router = Container::dispense("Router");
$result = $router->resolve(
$argv[1],
[
['scanner-driver', Router::lazyLoad('CLIControllers\ScannerDriver')],
['do-jobs', Router::lazyLoad('CLIControllers\DoJobs')],
['install-currency', Router::lazyLoad('CLIControllers\InstallCurrency')],
['encrypt-config', Router::lazyLoad('CLIControllers\EncryptConfig')],
['decrypt-config', Router::lazyLoad('CLIControllers\DecryptConfig')],
['handle-command', Router::lazyLoad('CLIControllers\HandleCommand')],
['pptest', Router::lazyLoad('CLIControllers\PPTest')],
['address-monitor', Router::lazyLoad('CLIControllers\AddressMonitor')],
]
);