-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsh
35 lines (26 loc) · 747 Bytes
/
sh
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
<?php
if(PHP_SAPI !== 'cli') {
die('This script can only be run from the command line.');
}
define('DS', DIRECTORY_SEPARATOR);
define('CPATH', __DIR__.DIRECTORY_SEPARATOR);
define('ROOTPATH', __DIR__ . DS);
chdir(CPATH);
$action = $argv[1] ?? 'help';
require_once CPATH."app".DS."sh".DS."init.php";
$sh = new App\Sh\sh;
if(empty($action)) {
call_user_func_array([$sh, 'help'], []);
} else {
$action = explode(':', $action);
if($action[0] == '--help') {
call_user_func_array([$sh, 'help'], []);
exit;
}
if(is_callable([$sh, $action[0]])){
call_user_func_array([$sh, $action[0]],[$argv]);
}else {
echo "Invalid command\n";
call_user_func_array([$sh, 'help'], []);
}
}