From 3cdaa4094fe7a8fa6db4885dd9a426053e845a53 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Fri, 31 Oct 2014 17:39:05 +0100 Subject: add quiet option, ref #8794 --- apps/files/command/scan.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index c63a3174271..6e4b3ee4bc3 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -39,11 +39,17 @@ class Scan extends Command { ) ->addOption( 'path', - null, + 'p', InputArgument::OPTIONAL, 'limit rescan to this path, eg. --path="files/Music"', '' ) + ->addOption( + 'quiet', + 'q', + InputOption::VALUE_NONE, + 'suppress output' + ) ->addOption( 'all', null, @@ -52,14 +58,16 @@ class Scan extends Command { ); } - protected function scanFiles($user, $path, OutputInterface $output) { + protected function scanFiles($user, $path, $quiet, OutputInterface $output) { $scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection()); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { - $output->writeln("Scanning $path"); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("Scanning $path"); - }); + if (!$quiet) { + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { + $output->writeln("Scanning $path"); + }); + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $output->writeln("Scanning $path"); + }); + } try { $scanner->scan($path); } catch (ForbiddenException $e) { @@ -75,6 +83,7 @@ class Scan extends Command { $users = $input->getArgument('user_id'); } $path = trim($input->getOption('path'), '/'); + $quiet = $input->getOption('quiet'); if (count($users) === 0) { $output->writeln("Please specify the user id to scan or \"--all\" to scan for all users"); @@ -86,7 +95,7 @@ class Scan extends Command { $user = $user->getUID(); } if ($this->userManager->userExists($user)) { - $this->scanFiles($user, $path, $output); + $this->scanFiles($user, $path, $quiet, $output); } else { $output->writeln("Unknown user $user"); } -- cgit v1.2.3