aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/User
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-26 14:54:51 +0200
committerJoas Schilling <coding@schilljs.com>2020-06-26 14:54:51 +0200
commitab21d69903c4360cbce59741624b6e765e3bd35f (patch)
tree8bed2d6af0d4bfef3766e356acc570b93eb9feb3 /core/Command/User
parented4afa55c1ccaef140ac310258ad837bf6af9557 (diff)
downloadnextcloud-server-ab21d69903c4360cbce59741624b6e765e3bd35f.tar.gz
nextcloud-server-ab21d69903c4360cbce59741624b6e765e3bd35f.zip
Add return value to all commands
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command/User')
-rw-r--r--core/Command/User/Add.php3
-rw-r--r--core/Command/User/Delete.php7
-rw-r--r--core/Command/User/Disable.php5
-rw-r--r--core/Command/User/Enable.php5
-rw-r--r--core/Command/User/Info.php3
-rw-r--r--core/Command/User/LastSeen.php5
-rw-r--r--core/Command/User/ListCommand.php5
-rw-r--r--core/Command/User/Report.php3
-rw-r--r--core/Command/User/ResetPassword.php3
-rw-r--r--core/Command/User/Setting.php2
10 files changed, 25 insertions, 16 deletions
diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php
index dfb2c9b8ad4..b75664f16f6 100644
--- a/core/Command/User/Add.php
+++ b/core/Command/User/Add.php
@@ -85,7 +85,7 @@ class Add extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$uid = $input->getArgument('uid');
if ($this->userManager->userExists($uid)) {
$output->writeln('<error>The user "' . $uid . '" already exists.</error>');
@@ -164,5 +164,6 @@ class Add extends Command {
$output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
}
}
+ return 0;
}
}
diff --git a/core/Command/User/Delete.php b/core/Command/User/Delete.php
index 37099749d08..c6c7700ce5a 100644
--- a/core/Command/User/Delete.php
+++ b/core/Command/User/Delete.php
@@ -55,18 +55,19 @@ class Delete extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
- return;
+ return 0;
}
if ($user->delete()) {
$output->writeln('<info>The specified user was deleted</info>');
- return;
+ return 0;
}
$output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
+ return 1;
}
}
diff --git a/core/Command/User/Disable.php b/core/Command/User/Disable.php
index 4967856beb9..7abb625c978 100644
--- a/core/Command/User/Disable.php
+++ b/core/Command/User/Disable.php
@@ -52,14 +52,15 @@ class Disable extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
- return;
+ return 1;
}
$user->setEnabled(false);
$output->writeln('<info>The specified user is disabled</info>');
+ return 0;
}
}
diff --git a/core/Command/User/Enable.php b/core/Command/User/Enable.php
index 5792ba9b752..c62eee87012 100644
--- a/core/Command/User/Enable.php
+++ b/core/Command/User/Enable.php
@@ -52,14 +52,15 @@ class Enable extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
- return;
+ return 1;
}
$user->setEnabled(true);
$output->writeln('<info>The specified user is enabled</info>');
+ return 0;
}
}
diff --git a/core/Command/User/Info.php b/core/Command/User/Info.php
index 52579a56031..ec5f9a4d1f7 100644
--- a/core/Command/User/Info.php
+++ b/core/Command/User/Info.php
@@ -65,7 +65,7 @@ class Info extends Base {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('user'));
if (is_null($user)) {
$output->writeln('<error>user not found</error>');
@@ -85,5 +85,6 @@ class Info extends Base {
'backend' => $user->getBackendClassName()
];
$this->writeArrayInOutputFormat($input, $output, $data);
+ return 0;
}
}
diff --git a/core/Command/User/LastSeen.php b/core/Command/User/LastSeen.php
index b60d88c8617..af80b1e1c05 100644
--- a/core/Command/User/LastSeen.php
+++ b/core/Command/User/LastSeen.php
@@ -56,11 +56,11 @@ class LastSeen extends Command {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
- return;
+ return 1;
}
$lastLogin = $user->getLastLogin();
@@ -73,5 +73,6 @@ class LastSeen extends Command {
$output->writeln($user->getUID() .
'`s last login: ' . $date->format('d.m.Y H:i'));
}
+ return 0;
}
}
diff --git a/core/Command/User/ListCommand.php b/core/Command/User/ListCommand.php
index 103a9993756..65305304bf6 100644
--- a/core/Command/User/ListCommand.php
+++ b/core/Command/User/ListCommand.php
@@ -81,10 +81,11 @@ class ListCommand extends Base {
);
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$users = $this->userManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
$this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool)$input->getOption('info')));
+ return 0;
}
/**
@@ -96,7 +97,7 @@ class ListCommand extends Base {
$keys = array_map(function (IUser $user) {
return $user->getUID();
}, $users);
-
+
$values = array_map(function (IUser $user) use ($detailed) {
if ($detailed) {
$groups = $this->groupManager->getUserGroupIds($user);
diff --git a/core/Command/User/Report.php b/core/Command/User/Report.php
index fff3924d324..b7fecee61bb 100644
--- a/core/Command/User/Report.php
+++ b/core/Command/User/Report.php
@@ -51,7 +51,7 @@ class Report extends Command {
->setDescription('shows how many users have access');
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$table = new Table($output);
$table->setHeaders(['User Report', '']);
$userCountArray = $this->countUsers();
@@ -75,6 +75,7 @@ class Report extends Command {
$table->setRows($rows);
$table->render();
+ return 0;
}
private function countUsers() {
diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php
index f5b0736d722..bcb3c774ef0 100644
--- a/core/Command/User/ResetPassword.php
+++ b/core/Command/User/ResetPassword.php
@@ -67,7 +67,7 @@ class ResetPassword extends Command {
;
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
$username = $input->getArgument('user');
/** @var $user \OCP\IUser */
@@ -134,5 +134,6 @@ class ResetPassword extends Command {
$output->writeln("<error>Error while resetting password!</error>");
return 1;
}
+ return 0;
}
}
diff --git a/core/Command/User/Setting.php b/core/Command/User/Setting.php
index 5a2c653bbdd..2ce09fba646 100644
--- a/core/Command/User/Setting.php
+++ b/core/Command/User/Setting.php
@@ -158,7 +158,7 @@ class Setting extends Base {
}
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$this->checkInput($input);
} catch (\InvalidArgumentException $e) {