summaryrefslogtreecommitdiffstats
path: root/core/command/app
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-04-09 11:45:07 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-04-09 11:46:52 +0200
commitdd5063bd491f26c514e3206a167c2888d6bc3310 (patch)
treef591b732f15a019465cf45cf66d896ebfa46e116 /core/command/app
parent56f1ffe820383ac82c208552213848c6a8deec6d (diff)
downloadnextcloud-server-dd5063bd491f26c514e3206a167c2888d6bc3310.tar.gz
nextcloud-server-dd5063bd491f26c514e3206a167c2888d6bc3310.zip
Add an option to get the output in plain, json or print_r syntax
Diffstat (limited to 'core/command/app')
-rw-r--r--core/command/app/listapps.php42
1 files changed, 35 insertions, 7 deletions
diff --git a/core/command/app/listapps.php b/core/command/app/listapps.php
index dbb04c41eed..8a790b56284 100644
--- a/core/command/app/listapps.php
+++ b/core/command/app/listapps.php
@@ -23,15 +23,18 @@
namespace OC\Core\Command\App;
-use Symfony\Component\Console\Command\Command;
+use OC\Core\Command\Base;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-class ListApps extends Command {
+class ListApps extends Base {
protected function configure() {
+ parent::configure();
+
$this
->setName('app:list')
- ->setDescription('List all available apps');
+ ->setDescription('List all available apps')
+ ;
}
protected function execute(InputInterface $input, OutputInterface $output) {
@@ -51,13 +54,38 @@ class ListApps extends Command {
sort($enabledApps);
sort($disabledApps);
- $output->writeln('Enabled:');
+ $apps = ['enabled' => [], 'disabled' => []];
foreach ($enabledApps as $app) {
- $output->writeln(' - ' . $app . (isset($versions[$app]) ? ' (' . $versions[$app] . ')' : ''));
+ if (isset($versions[$app])) {
+ $apps['enabled'][$app] = $versions[$app];
+ } else {
+ $apps['enabled'][$app] = true;
+ }
}
- $output->writeln('Disabled:');
+
foreach ($disabledApps as $app) {
- $output->writeln(' - ' . $app . (isset($versions[$app]) ? ' (' . $versions[$app] . ')' : ''));
+ if (isset($versions[$app])) {
+ $apps['disabled'][$app] = $versions[$app];
+ } else {
+ $apps['disabled'][$app] = false;
+ }
+ }
+ $this->writeArrayInOutputFormat($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:
+ $output->writeln('Enabled:');
+ parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
+ $output->writeln('Disabled:');
+ parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
+ break;
}
}
}