Merge pull request #4642 from masakik/master

Minor enhancement to console.php
This commit is contained in:
Morris Jobke 2013-08-29 12:05:32 -07:00
commit 0a23ac18bc
2 changed files with 28 additions and 9 deletions

View File

@ -1,3 +1,4 @@
<?php <?php
/** /**
* Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl> * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
@ -20,17 +21,32 @@ if (!OC::$CLI) {
exit(0); exit(0);
} }
$self = basename($argv[0]);
if ($argc <= 1) { if ($argc <= 1) {
echo "Usage:" . PHP_EOL; $argv[1] = "help";
echo " " . basename($argv[0]) . " <command>" . PHP_EOL;
exit(0);
} }
$command = $argv[1]; $command = $argv[1];
array_shift($argv); array_shift($argv);
if ($command === 'files:scan') { switch ($command) {
case 'files:scan':
require_once 'apps/files/console/scan.php'; require_once 'apps/files/console/scan.php';
} else { 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 "Unknown command '$command'" . PHP_EOL;
echo "For available commands type ". $self . " help" . PHP_EOL;
break;
} }

View File

@ -33,8 +33,11 @@ try {
'version'=>implode('.', OC_Util::getVersion()), 'version'=>implode('.', OC_Util::getVersion()),
'versionstring'=>OC_Util::getVersionString(), 'versionstring'=>OC_Util::getVersionString(),
'edition'=>OC_Util::getEditionString()); 'edition'=>OC_Util::getEditionString());
if (OC::$CLI) {
print_r($values);
} else {
echo(json_encode($values)); echo(json_encode($values));
}
} catch (Exception $ex) { } catch (Exception $ex) {
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);