Add global --no-warning option to occ in order not to pollute output with warnings

This commit is contained in:
Victor Dubiniuk 2016-02-18 02:42:00 +03:00
parent 99051cdbe5
commit 972e0c62b3
2 changed files with 23 additions and 2 deletions

View 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;

View 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()) {