diff options
Diffstat (limited to 'apps/files_trashbin/lib/Command/CleanUp.php')
-rw-r--r-- | apps/files_trashbin/lib/Command/CleanUp.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/files_trashbin/lib/Command/CleanUp.php b/apps/files_trashbin/lib/Command/CleanUp.php index b727dd9e133..d2f8f72be8b 100644 --- a/apps/files_trashbin/lib/Command/CleanUp.php +++ b/apps/files_trashbin/lib/Command/CleanUp.php @@ -29,8 +29,10 @@ use OCP\IUserBackend; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Exception\InvalidOptionException; class CleanUp extends Command { @@ -62,13 +64,21 @@ class CleanUp extends Command { ->addArgument( 'user_id', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - 'remove deleted files of the given user(s), if no user is given all deleted files will be removed' + 'remove deleted files of the given user(s)' + ) + ->addOption( + 'all-users', + null, + InputOption::VALUE_NONE, + 'run action on all users' ); } protected function execute(InputInterface $input, OutputInterface $output) { $users = $input->getArgument('user_id'); - if (!empty($users)) { + if ((!empty($users)) and ($input->getOption('all-users'))) { + throw new InvalidOptionException('Either specify a user_id or --all-users'); + } elseif (!empty($users)) { foreach ($users as $user) { if ($this->userManager->userExists($user)) { $output->writeln("Remove deleted files of <info>$user</info>"); @@ -77,8 +87,8 @@ class CleanUp extends Command { $output->writeln("<error>Unknown user $user</error>"); } } - } else { - $output->writeln('Remove all deleted files'); + } elseif ($input->getOption('all-users')) { + $output->writeln('Remove deleted files for all users'); foreach ($this->userManager->getBackends() as $backend) { $name = get_class($backend); if ($backend instanceof IUserBackend) { @@ -96,6 +106,8 @@ class CleanUp extends Command { $offset += $limit; } while (count($users) >= $limit); } + } else { + throw new InvalidOptionException('Either specify a user_id or --all-users'); } } |