diff --git a/core/Command/Group/AddUser.php b/core/Command/Group/AddUser.php
index b5d0068acc654..141916953abab 100644
--- a/core/Command/Group/AddUser.php
+++ b/core/Command/Group/AddUser.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,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$group->addUser($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 [];
+ }
+
+ $members = array_map(static fn (IUser $user) => $user->getUID(), $group->searchUsers($context->getCurrentWord()));
+ $users = array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
+ return array_diff($users, $members);
+ }
+ return [];
+ }
}
diff --git a/core/Command/Group/Delete.php b/core/Command/Group/Delete.php
index be97be83407cc..2596b461d1708 100644
--- a/core/Command/Group/Delete.php
+++ b/core/Command/Group/Delete.php
@@ -27,7 +27,9 @@
namespace OC\Core\Command\Group;
use OC\Core\Command\Base;
+use OCP\IGroup;
use OCP\IGroupManager;
+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;
@@ -74,4 +76,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
return 0;
}
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'groupid') {
+ return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord()));
+ }
+ return [];
+ }
}
diff --git a/core/Command/Group/Info.php b/core/Command/Group/Info.php
index 180055e83ea55..5e9fa6611309f 100644
--- a/core/Command/Group/Info.php
+++ b/core/Command/Group/Info.php
@@ -28,6 +28,7 @@
use OC\Core\Command\Base;
use OCP\IGroup;
use OCP\IGroupManager;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -79,4 +80,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}
}
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'groupid') {
+ return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord()));
+ }
+ return [];
+ }
}
diff --git a/core/Command/Group/RemoveUser.php b/core/Command/Group/RemoveUser.php
index 4af66480f28cb..2b9c4eaec529b 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 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$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 [];
+ }
}
diff --git a/core/Command/User/Delete.php b/core/Command/User/Delete.php
index 37e09ca69caa8..9624f04fa18f1 100644
--- a/core/Command/User/Delete.php
+++ b/core/Command/User/Delete.php
@@ -24,13 +24,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 Delete extends Command {
+class Delete extends Base {
/** @var IUserManager */
protected $userManager;
@@ -68,4 +70,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('The specified user could not be deleted. Please check the logs.');
return 1;
}
+
+ /**
+ * @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(), $this->userManager->search($context->getCurrentWord()));
+ }
+ return [];
+ }
}
diff --git a/core/Command/User/Disable.php b/core/Command/User/Disable.php
index e4f43e26f5903..9120d28cc1f64 100644
--- a/core/Command/User/Disable.php
+++ b/core/Command/User/Disable.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 Disable extends Command {
+class Disable extends Base {
/** @var IUserManager */
protected $userManager;
@@ -63,4 +65,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('The specified user is disabled');
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 [];
+ }
}
diff --git a/core/Command/User/Enable.php b/core/Command/User/Enable.php
index 80efec3bc3f8f..eb548a74d7eb4 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 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('The specified user is enabled');
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 [];
+ }
}
diff --git a/core/Command/User/Info.php b/core/Command/User/Info.php
index 36bfa0b6d5b1f..a93f65b7dce2d 100644
--- a/core/Command/User/Info.php
+++ b/core/Command/User/Info.php
@@ -28,6 +28,7 @@
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\Input\InputOption;
@@ -110,4 +111,16 @@ protected function getStorageInfo(IUser $user): array {
'quota' => $storage['quota'],
];
}
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'user') {
+ return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
+ }
+ return [];
+ }
}
diff --git a/core/Command/User/LastSeen.php b/core/Command/User/LastSeen.php
index e56ddd5087f2f..dc01ca549f3a4 100644
--- a/core/Command/User/LastSeen.php
+++ b/core/Command/User/LastSeen.php
@@ -25,13 +25,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 LastSeen extends Command {
+class LastSeen extends Base {
/** @var IUserManager */
protected $userManager;
@@ -73,4 +75,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
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(), $this->userManager->search($context->getCurrentWord()));
+ }
+ return [];
+ }
}
diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php
index 798f5dad58581..174a9f4068d0f 100644
--- a/core/Command/User/ResetPassword.php
+++ b/core/Command/User/ResetPassword.php
@@ -27,8 +27,10 @@
*/
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\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -37,7 +39,7 @@
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
-class ResetPassword extends Command {
+class ResetPassword extends Base {
/** @var IUserManager */
protected $userManager;
@@ -133,4 +135,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
return 0;
}
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'user') {
+ return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
+ }
+ return [];
+ }
}
diff --git a/core/Command/User/Setting.php b/core/Command/User/Setting.php
index 87fb6905de96f..3e4830127cd08 100644
--- a/core/Command/User/Setting.php
+++ b/core/Command/User/Setting.php
@@ -29,6 +29,7 @@
use OCP\IConfig;
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\Input\InputOption;
@@ -255,4 +256,27 @@ protected function getUserSettings($uid, $app) {
return $settings;
}
+
+ /**
+ * @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(), $this->userManager->search($context->getCurrentWord()));
+ }
+ if ($argumentName === 'app') {
+ $userId = $context->getWordAtIndex($context->getWordIndex() - 1);
+ $settings = $this->getUserSettings($userId, '');
+ return array_keys($settings);
+ }
+ if ($argumentName === 'key') {
+ $userId = $context->getWordAtIndex($context->getWordIndex() - 2);
+ $app = $context->getWordAtIndex($context->getWordIndex() - 1);
+ $settings = $this->getUserSettings($userId, $app);
+ return array_keys($settings[$app]);
+ }
+ return [];
+ }
}