diff options
Diffstat (limited to 'core/Command/Group/RemoveUser.php')
-rw-r--r-- | core/Command/Group/RemoveUser.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/Command/Group/RemoveUser.php b/core/Command/Group/RemoveUser.php index 4af66480f28..2b9c4eaec52 100644 --- a/core/Command/Group/RemoveUser.php +++ b/core/Command/Group/RemoveUser.php @@ -24,8 +24,11 @@ namespace OC\Core\Command\Group; use OC\Core\Command\Base; +use OCP\IGroup; use OCP\IGroupManager; +use OCP\IUser; use OCP\IUserManager; +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; @@ -75,4 +78,24 @@ class RemoveUser extends Base { $group->removeUser($user); return 0; } + + /** + * @param string $argumentName + * @param CompletionContext $context + * @return string[] + */ + public function completeArgumentValues($argumentName, CompletionContext $context) { + if ($argumentName === 'group') { + return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord())); + } + if ($argumentName === 'user') { + $groupId = $context->getWordAtIndex($context->getWordIndex() - 1); + $group = $this->groupManager->get($groupId); + if ($group === null) { + return []; + } + return array_map(static fn (IUser $user) => $user->getUID(), $group->searchUsers($context->getCurrentWord())); + } + return []; + } } |