]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add global --no-warning option to occ in order not to pollute output with warnings
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>
Wed, 17 Feb 2016 23:42:00 +0000 (02:42 +0300)
committerVictor Dubiniuk <victor.dubiniuk@gmail.com>
Thu, 18 Feb 2016 21:33:48 +0000 (00:33 +0300)
console.php
lib/private/console/application.php

index d8c23d4ce000b40233d1feedc44989012301579b..eb6c84c3cf89d2b8994db6636dc41176ea596d6b 100644 (file)
@@ -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;
index 10ff69b1c80bd5dc8590041e6f3e54a1c190d6e7..0895f1788af91684ab8b64de3467185cca4f4803 100644 (file)
@@ -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()) {