diff options
author | Stephen Colebrook <scolebrook@mac.com> | 2015-12-22 16:28:32 -0500 |
---|---|---|
committer | Stephen Colebrook <scolebrook@mac.com> | 2015-12-22 16:28:32 -0500 |
commit | 064580a56ef33e2236fe4b9f81c4928a61080047 (patch) | |
tree | 96f738cd04290d2f1ddc48be81ec1d80affe15da /apps/user_ldap/command | |
parent | 5e3710d74690c44c51c483729a210d1f8d109ce8 (diff) | |
download | nextcloud-server-064580a56ef33e2236fe4b9f81c4928a61080047.tar.gz nextcloud-server-064580a56ef33e2236fe4b9f81c4928a61080047.zip |
Add an option to occ ldap:showremnants to output a json encoded array for use in scripts and other tools.
Diffstat (limited to 'apps/user_ldap/command')
-rw-r--r-- | apps/user_ldap/command/showremnants.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/user_ldap/command/showremnants.php b/apps/user_ldap/command/showremnants.php index 72217c50972..1aa3c49475f 100644 --- a/apps/user_ldap/command/showremnants.php +++ b/apps/user_ldap/command/showremnants.php @@ -24,6 +24,7 @@ namespace OCA\user_ldap\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use OCA\user_ldap\lib\user\DeletedUsersIndex; @@ -50,7 +51,7 @@ class ShowRemnants extends Command { $this ->setName('ldap:show-remnants') ->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.') - ; + ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.'); } /** @@ -70,18 +71,21 @@ class ShowRemnants extends Command { $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; $lastLogin = ($user->getLastLogin() > 0) ? $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; - $rows[] = array( - $user->getOCName(), - $user->getDisplayName(), - $user->getUid(), - $user->getDN(), - $lastLogin, - $user->getHomePath(), - $hAS + $rows[] = array('ocName' => $user->getOCName(), + 'displayName' => $user->getDisplayName(), + 'uid' => $user->getUid(), + 'dn' => $user->getDN(), + 'lastLogin' => $lastLogin, + 'homePath' => $user->getHomePath(), + 'sharer' => $hAS ); } - $table->setRows($rows); - $table->render($output); + if ($input->getOption('json')) { + $output->writeln(json_encode($rows)); + } else { + $table->setRows($rows); + $table->render($output); + } } } |