]> source.dussan.org Git - nextcloud-server.git/commitdiff
change handling in app:list
authorJoas Schilling <nickvergessen@owncloud.com>
Thu, 9 Apr 2015 12:44:30 +0000 (14:44 +0200)
committerJoas Schilling <nickvergessen@owncloud.com>
Thu, 9 Apr 2015 12:44:30 +0000 (14:44 +0200)
core/command/app/listapps.php
core/command/base.php

index 8a790b56284b3b123955e9898956971349f4d285..37a1d645ed43a2e1558d89c57d945ca2205cb751 100644 (file)
@@ -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;
                }
        }
 }
index b43022a550c567258478283b303088f0bbf2e9b2..c2d5cf97f02da0272c879c8332fd13d325a2bfc3 100644 (file)
@@ -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':