added --enabled and --disabled options to occ app:list

Signed-off-by: Adam Blakey <adam@blakey.family>
pull/33546/head
Adam Blakey 2 years ago
parent cb97e8f15c
commit e9fb7a2885

@ -7,6 +7,7 @@
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
* @author Adam Blakey <adam@blakey.family>
*
* @license AGPL-3.0
*
@ -52,6 +53,18 @@ class ListApps extends Base {
InputOption::VALUE_REQUIRED,
'true - limit to shipped apps only, false - limit to non-shipped apps only'
)
->addOption(
'enabled',
null,
InputOption::VALUE_NONE,
'shows only enabled apps'
)
->addOption(
'disabled',
null,
InputOption::VALUE_NONE,
'shows only disabled apps'
)
;
}
@ -62,6 +75,24 @@ class ListApps extends Base {
$shippedFilter = null;
}
if ($input->getOption('enabled') !== '' && $input->getOption('disabled') !== '') {
$output->writeln('<error>You can only use at most one of the options ' .
'"enabled" or "disabled"</error>');
return 1;
}
else if ($input->getOption('enabled') !== '') {
$showEnabledApps = true;
$showDisabledApps = false;
}
else if ($input->getOption('disabled') !== '') {
$showEnabledApps = false;
$showDisabledApps = true;
}
else {
$showEnabledApps = true;
$showDisabledApps = true;
}
$apps = \OC_App::getAllApps();
$enabledApps = $disabledApps = [];
$versions = \OC_App::getAppVersions();
@ -78,16 +109,24 @@ class ListApps extends Base {
}
}
$apps = ['enabled' => [], 'disabled' => []];
$apps = [];
if ($showEnabledApps) {
$apps['enabled'] = [];
sort($enabledApps);
foreach ($enabledApps as $app) {
$apps['enabled'][$app] = $versions[$app] ?? true;
sort($enabledApps);
foreach ($enabledApps as $app) {
$apps['enabled'][$app] = $versions[$app] ?? true;
}
}
sort($disabledApps);
foreach ($disabledApps as $app) {
$apps['disabled'][$app] = $versions[$app] ?? null;
if ($showDisabledApps) {
$apps['disabled'] = [];
sort($disabledApps);
foreach ($disabledApps as $app) {
$apps['disabled'][$app] = $versions[$app] ?? null;
}
}
$this->writeAppList($input, $output, $apps);
@ -102,11 +141,15 @@ class ListApps extends Base {
protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
switch ($input->getOption('output')) {
case self::OUTPUT_FORMAT_PLAIN:
$output->writeln('Enabled:');
parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
$output->writeln('Disabled:');
parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
if ($items['enabled']) {
$output->writeln('Enabled:');
parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
}
if ($items['disabled']) {
$output->writeln('Disabled:');
parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
}
break;
default:

Loading…
Cancel
Save