Base.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace OC\Core\Command\TwoFactorAuth;
  22. use OCP\IUserManager;
  23. use OCP\IUser;
  24. use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
  25. use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
  26. class Base extends \OC\Core\Command\Base implements CompletionAwareInterface {
  27. /** @var IUserManager */
  28. protected $userManager;
  29. /**
  30. * Return possible values for the named option
  31. *
  32. * @param string $optionName
  33. * @param CompletionContext $context
  34. * @return string[]
  35. */
  36. public function completeOptionValues($optionName, CompletionContext $context) {
  37. return [];
  38. }
  39. /**
  40. * Return possible values for the named argument
  41. *
  42. * @param string $argumentName
  43. * @param CompletionContext $context
  44. * @return string[]
  45. */
  46. public function completeArgumentValues($argumentName, CompletionContext $context) {
  47. if ($argumentName === 'uid') {
  48. return array_map(function(IUser $user) {
  49. return $user->getUID();
  50. }, $this->userManager->search($context->getCurrentWord(), 100));
  51. }
  52. return [];
  53. }
  54. }