aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/App
diff options
context:
space:
mode:
authorAdam Blakey <adam@blakey.family>2022-08-15 17:39:29 +0200
committerAdam Blakey <adam@blakey.family>2022-08-15 18:11:17 +0200
commite9fb7a288515c92e9fa4314cc789dbbe380a4828 (patch)
treeac9013250b03b0b8c5400761234fc5a143dfc85f /core/Command/App
parentcb97e8f15c75cc46e345ebfc79dcad1b9c48bd01 (diff)
downloadnextcloud-server-e9fb7a288515c92e9fa4314cc789dbbe380a4828.tar.gz
nextcloud-server-e9fb7a288515c92e9fa4314cc789dbbe380a4828.zip
added --enabled and --disabled options to occ app:list
Signed-off-by: Adam Blakey <adam@blakey.family>
Diffstat (limited to 'core/Command/App')
-rw-r--r--core/Command/App/ListApps.php67
1 files changed, 55 insertions, 12 deletions
diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php
index 6f8858c8858..2d01e9f5904 100644
--- a/core/Command/App/ListApps.php
+++ b/core/Command/App/ListApps.php
@@ -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: