Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>2016-02-18 02:42:00 +0300
committerVictor Dubiniuk <victor.dubiniuk@gmail.com>2016-02-19 00:33:48 +0300
commit972e0c62b38d0a77023b6771c0f8867b1c33d8c4 (patch)
tree090e6730cddd908d82eda780f18e93a8563422c5
parent99051cdbe54c6efa131498f699c1d29642885c74 (diff)
Add global --no-warning option to occ in order not to pollute output with warnings
-rw-r--r--console.php3
-rw-r--r--lib/private/console/application.php22
2 files changed, 23 insertions, 2 deletions
diff --git a/console.php b/console.php
index d8c23d4ce00..eb6c84c3cf8 100644
--- a/console.php
+++ b/console.php
@@ -27,6 +27,7 @@
*/
use OC\Console\Application;
+use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
define('OC_CONSOLE', 1);
@@ -81,7 +82,7 @@ try {
}
$application = new Application(\OC::$server->getConfig(), \OC::$server->getEventDispatcher(), \OC::$server->getRequest());
- $application->loadCommands(new ConsoleOutput());
+ $application->loadCommands(new ArgvInput(), new ConsoleOutput());
$application->run();
} catch (Exception $ex) {
echo "An unhandled exception has been thrown:" . PHP_EOL;
diff --git a/lib/private/console/application.php b/lib/private/console/application.php
index 10ff69b1c80..0895f1788af 100644
--- a/lib/private/console/application.php
+++ b/lib/private/console/application.php
@@ -31,6 +31,7 @@ use OCP\IRequest;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -56,12 +57,31 @@ class Application {
}
/**
+ * @param InputInterface $input
* @param OutputInterface $output
* @throws \Exception
*/
- public function loadCommands(OutputInterface $output) {
+ public function loadCommands(InputInterface $input, OutputInterface $output) {
// $application is required to be defined in the register_command scripts
$application = $this->application;
+ $inputDefinition = $application->getDefinition();
+ $inputDefinition->addOption(
+ new InputOption(
+ 'no-warnings',
+ null,
+ InputOption::VALUE_NONE,
+ 'Skip global warnings, show command output only',
+ null
+ )
+ );
+ try {
+ $input->bind($inputDefinition);
+ } catch (\RuntimeException $e) {
+ //expected if there are extra options
+ }
+ if ($input->getOption('no-warnings')) {
+ $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
+ }
require_once __DIR__ . '/../../../core/register_command.php';
if ($this->config->getSystemValue('installed', false)) {
if (\OCP\Util::needUpgrade()) {