Browse Source

change handling in app:list

tags/v8.1.0alpha1
Joas Schilling 9 years ago
parent
commit
98bdfa1518
2 changed files with 26 additions and 23 deletions
  1. 21
    23
      core/command/app/listapps.php
  2. 5
    0
      core/command/base.php

+ 21
- 23
core/command/app/listapps.php View 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;
}
}
}

+ 5
- 0
core/command/base.php View 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':

Loading…
Cancel
Save