summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-04-09 14:44:30 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-04-09 14:44:30 +0200
commit98bdfa1518da32782f8a906e6643c0cde6c4dfc9 (patch)
tree577f5fd49f248607f9fc4afa6a80522fe1b06f48
parentdef3b687ee9881d9842c5e916c2a4fb405f88925 (diff)
downloadnextcloud-server-98bdfa1518da32782f8a906e6643c0cde6c4dfc9.tar.gz
nextcloud-server-98bdfa1518da32782f8a906e6643c0cde6c4dfc9.zip
change handling in app:list
-rw-r--r--core/command/app/listapps.php44
-rw-r--r--core/command/base.php5
2 files changed, 26 insertions, 23 deletions
diff --git a/core/command/app/listapps.php b/core/command/app/listapps.php
index 8a790b56284..37a1d645ed4 100644
--- a/core/command/app/listapps.php
+++ b/core/command/app/listapps.php
@@ -39,8 +39,7 @@ class ListApps extends Base {
protected function execute(InputInterface $input, OutputInterface $output) {
$apps = \OC_App::getAllApps();
- $enabledApps = array();
- $disabledApps = array();
+ $enabledApps = $disabledApps = [];
$versions = \OC_App::getAppVersions();
//sort enabled apps above disabled apps
@@ -52,40 +51,39 @@ class ListApps extends Base {
}
}
- sort($enabledApps);
- sort($disabledApps);
$apps = ['enabled' => [], 'disabled' => []];
+
+ sort($enabledApps);
foreach ($enabledApps as $app) {
- if (isset($versions[$app])) {
- $apps['enabled'][$app] = $versions[$app];
- } else {
- $apps['enabled'][$app] = true;
- }
+ $apps['enabled'][$app] = (isset($versions[$app])) ? $versions[$app] : '';
}
+ sort($disabledApps);
foreach ($disabledApps as $app) {
- if (isset($versions[$app])) {
- $apps['disabled'][$app] = $versions[$app];
- } else {
- $apps['disabled'][$app] = false;
- }
+ $apps['disabled'][$app] = (isset($versions[$app])) ? $versions[$app] : '';
}
- $this->writeArrayInOutputFormat($input, $output, $apps);
+
+ $this->writeAppList($input, $output, $apps);
}
- protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items) {
- $outputFormat = $input->getOption('output');
- switch ($outputFormat) {
- case 'json':
- case 'print':
- parent::writeArrayInOutputFormat($input, $output, $items);
- break;
- default:
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @param array $items
+ */
+ protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
+ switch ($input->getOption('output')) {
+ case 'plain':
$output->writeln('Enabled:');
parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
+
$output->writeln('Disabled:');
parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
break;
+
+ default:
+ parent::writeArrayInOutputFormat($input, $output, $items);
+ break;
}
}
}
diff --git a/core/command/base.php b/core/command/base.php
index b43022a550c..c2d5cf97f02 100644
--- a/core/command/base.php
+++ b/core/command/base.php
@@ -39,6 +39,11 @@ class Base extends Command {
;
}
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @param array $items
+ */
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items) {
switch ($input->getOption('output')) {
case 'json':