diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-10-31 17:39:05 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-12-04 13:44:30 +0100 |
commit | 3cdaa4094fe7a8fa6db4885dd9a426053e845a53 (patch) | |
tree | a7d37cdca516e16a814170e5b497cdf151014491 /apps/files/command | |
parent | 7ef6df04da739af651afdcdbda6ccb095d1a90f7 (diff) | |
download | nextcloud-server-3cdaa4094fe7a8fa6db4885dd9a426053e845a53.tar.gz nextcloud-server-3cdaa4094fe7a8fa6db4885dd9a426053e845a53.zip |
add quiet option, ref #8794
Diffstat (limited to 'apps/files/command')
-rw-r--r-- | apps/files/command/scan.php | 27 |
1 files 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,12 +39,18 @@ 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, InputOption::VALUE_NONE, @@ -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 <info>$path</info>"); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("Scanning <info>$path</info>"); - }); + if (!$quiet) { + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { + $output->writeln("Scanning <info>$path</info>"); + }); + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $output->writeln("Scanning <info>$path</info>"); + }); + } 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("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>"); @@ -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("<error>Unknown user $user</error>"); } |