Skip to content
Snippets Groups Projects
Commit 98bdfa15 authored by Joas Schilling's avatar Joas Schilling
Browse files

change handling in app:list

parent def3b687
Branches
No related tags found
No related merge requests found
...@@ -39,8 +39,7 @@ class ListApps extends Base { ...@@ -39,8 +39,7 @@ class ListApps extends Base {
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$apps = \OC_App::getAllApps(); $apps = \OC_App::getAllApps();
$enabledApps = array(); $enabledApps = $disabledApps = [];
$disabledApps = array();
$versions = \OC_App::getAppVersions(); $versions = \OC_App::getAppVersions();
//sort enabled apps above disabled apps //sort enabled apps above disabled apps
...@@ -52,40 +51,39 @@ class ListApps extends Base { ...@@ -52,40 +51,39 @@ class ListApps extends Base {
} }
} }
sort($enabledApps);
sort($disabledApps);
$apps = ['enabled' => [], 'disabled' => []]; $apps = ['enabled' => [], 'disabled' => []];
sort($enabledApps);
foreach ($enabledApps as $app) { foreach ($enabledApps as $app) {
if (isset($versions[$app])) { $apps['enabled'][$app] = (isset($versions[$app])) ? $versions[$app] : '';
$apps['enabled'][$app] = $versions[$app];
} else {
$apps['enabled'][$app] = true;
}
} }
sort($disabledApps);
foreach ($disabledApps as $app) { foreach ($disabledApps as $app) {
if (isset($versions[$app])) { $apps['disabled'][$app] = (isset($versions[$app])) ? $versions[$app] : '';
$apps['disabled'][$app] = $versions[$app];
} else {
$apps['disabled'][$app] = false;
} }
}
$this->writeArrayInOutputFormat($input, $output, $apps); $this->writeAppList($input, $output, $apps);
} }
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items) { /**
$outputFormat = $input->getOption('output'); * @param InputInterface $input
switch ($outputFormat) { * @param OutputInterface $output
case 'json': * @param array $items
case 'print': */
parent::writeArrayInOutputFormat($input, $output, $items); protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
break; switch ($input->getOption('output')) {
default: case 'plain':
$output->writeln('Enabled:'); $output->writeln('Enabled:');
parent::writeArrayInOutputFormat($input, $output, $items['enabled']); parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
$output->writeln('Disabled:'); $output->writeln('Disabled:');
parent::writeArrayInOutputFormat($input, $output, $items['disabled']); parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
break; break;
default:
parent::writeArrayInOutputFormat($input, $output, $items);
break;
} }
} }
} }
...@@ -39,6 +39,11 @@ class Base extends Command { ...@@ -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) { protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items) {
switch ($input->getOption('output')) { switch ($input->getOption('output')) {
case 'json': case 'json':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment