Merge pull request #33546 from adam-blakey/show-enabled-and-disabled-apps

pull/44281/head
John Molakvoæ 2 months ago committed by GitHub
commit fcde3b22a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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
*
@ -51,6 +52,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'
)
;
}
@ -61,6 +74,9 @@ class ListApps extends Base {
$shippedFilter = null;
}
$showEnabledApps = $input->getOption('enabled') || !$input->getOption('disabled');
$showDisabledApps = $input->getOption('disabled') || !$input->getOption('enabled');
$apps = \OC_App::getAllApps();
$enabledApps = $disabledApps = [];
$versions = \OC_App::getAppVersions();
@ -77,16 +93,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] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
if ($showDisabledApps) {
$apps['disabled'] = [];
sort($disabledApps);
foreach ($disabledApps as $app) {
$apps['disabled'][$app] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
}
}
$this->writeAppList($input, $output, $apps);
@ -101,11 +125,15 @@ class ListApps extends Base {
protected function writeAppList(InputInterface $input, OutputInterface $output, $items): void {
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 (isset($items['enabled'])) {
$output->writeln('Enabled:');
parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
}
if (isset($items['disabled'])) {
$output->writeln('Disabled:');
parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
}
break;
default:

Loading…
Cancel
Save