added help and status commands

switch structure enables many commands seamlessy.
also added some help and status command.
This commit is contained in:
Masaki Kawabata Neto 2013-08-29 10:00:30 -03:00
parent 301cce54cc
commit 98a04d7c73
1 changed files with 22 additions and 7 deletions

View File

@ -20,17 +20,32 @@ if (!OC::$CLI) {
exit(0);
}
$self = basename($argv[0]);
if ($argc <= 1) {
echo "Usage:" . PHP_EOL;
echo " " . basename($argv[0]) . " <command>" . PHP_EOL;
exit(0);
$argv[1] = "help";
}
$command = $argv[1];
array_shift($argv);
if ($command === 'files:scan') {
require_once 'apps/files/console/scan.php';
} else {
echo "Unknown command '$command'" . PHP_EOL;
switch ($command) {
case 'files:scan':
require_once 'apps/files/console/scan.php';
break;
case 'status':
require_once 'status.php';
break;
case 'help':
echo "Usage:" . PHP_EOL;
echo " " . $self . " <command>" . PHP_EOL;
echo PHP_EOL;
echo "Available commands:" . PHP_EOL;
echo " files:scan -> rescan filesystem" .PHP_EOL;
echo " status -> show some status information" .PHP_EOL;
echo " help -> show this help screen" .PHP_EOL;
break;
default:
echo "Unknown command '$command'" . PHP_EOL;
echo "For available commands type ". $self . " help" . PHP_EOL;
break;
}