diff options
author | Joas Schilling <coding@schilljs.com> | 2022-04-08 11:40:05 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-04-08 11:54:44 +0200 |
commit | cfd2e8cc2026222866dd78a77fecd8ed44532634 (patch) | |
tree | cb2685ad69694c7948e06e07b04a2ba068ee0a80 /core/Command/User/Enable.php | |
parent | 69378e15347630cdf4c3c7465a951857926e52ec (diff) | |
download | nextcloud-server-cfd2e8cc2026222866dd78a77fecd8ed44532634.tar.gz nextcloud-server-cfd2e8cc2026222866dd78a77fecd8ed44532634.zip |
Allow to autocomplete user and group ids in commands
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command/User/Enable.php')
-rw-r--r-- | core/Command/User/Enable.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/core/Command/User/Enable.php b/core/Command/User/Enable.php index 80efec3bc3f..eb548a74d7e 100644 --- a/core/Command/User/Enable.php +++ b/core/Command/User/Enable.php @@ -23,13 +23,15 @@ */ namespace OC\Core\Command\User; +use OC\Core\Command\Base; +use OCP\IUser; use OCP\IUserManager; -use Symfony\Component\Console\Command\Command; +use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Enable extends Command { +class Enable extends Base { /** @var IUserManager */ protected $userManager; @@ -63,4 +65,22 @@ class Enable extends Command { $output->writeln('<info>The specified user is enabled</info>'); return 0; } + + /** + * @param string $argumentName + * @param CompletionContext $context + * @return string[] + */ + public function completeArgumentValues($argumentName, CompletionContext $context) { + if ($argumentName === 'uid') { + return array_map( + static fn (IUser $user) => $user->getUID(), + array_filter( + $this->userManager->search($context->getCurrentWord()), + static fn (IUser $user) => !$user->isEnabled() + ) + ); + } + return []; + } } |