forked from agentejo/cockpit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cp
executable file
·38 lines (27 loc) · 783 Bytes
/
cp
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
#!/usr/bin/env php
<?php
if (PHP_SAPI !== 'cli') {
exit('Script needs to be run from Command Line Interface (cli)');
}
define('COCKPIT_CLI', true);
include_once(__DIR__.'/bootstrap.php');
$_REQUEST = CLI::opts(); // make option available via $app->param()
$app = cockpit();
if (isset($argv[1])) {
$cmd = str_replace('../', '', $argv[1]);
$script = $app->path("#config:cli/{$cmd}.php");
if (!$script) {
$script = $app->path("#cli:{$cmd}.php");
}
switch ($cmd) {
case 'test':
CLI::writeln('Yepp!', true);
break;
default:
if ($script) {
include($script);
} else {
CLI::writeln("Error: Command \"{$cmd}\" not found!", false);
}
}
}