2013-11-25 20:34:16 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Joas Schilling <nickvergessen@owncloud.com>
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
* @author Robin Appelman <icewind@owncloud.com>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
2013-11-25 20:34:16 +04:00
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2013-11-25 20:34:16 +04:00
|
|
|
namespace OC\Core\Command\App;
|
|
|
|
|
2015-04-09 12:45:07 +03:00
|
|
|
use OC\Core\Command\Base;
|
2013-11-25 20:34:16 +04:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
2015-04-09 12:45:07 +03:00
|
|
|
class ListApps extends Base {
|
2013-11-25 20:34:16 +04:00
|
|
|
protected function configure() {
|
2015-04-09 12:45:07 +03:00
|
|
|
parent::configure();
|
|
|
|
|
2013-11-25 20:34:16 +04:00
|
|
|
$this
|
|
|
|
->setName('app:list')
|
2015-04-09 12:45:07 +03:00
|
|
|
->setDescription('List all available apps')
|
|
|
|
;
|
2013-11-25 20:34:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
|
|
|
$apps = \OC_App::getAllApps();
|
2015-04-09 15:44:30 +03:00
|
|
|
$enabledApps = $disabledApps = [];
|
2015-03-03 12:26:09 +03:00
|
|
|
$versions = \OC_App::getAppVersions();
|
2013-11-25 20:34:16 +04:00
|
|
|
|
|
|
|
//sort enabled apps above disabled apps
|
|
|
|
foreach ($apps as $app) {
|
|
|
|
if (\OC_App::isEnabled($app)) {
|
|
|
|
$enabledApps[] = $app;
|
|
|
|
} else {
|
|
|
|
$disabledApps[] = $app;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-09 12:45:07 +03:00
|
|
|
$apps = ['enabled' => [], 'disabled' => []];
|
2015-04-09 15:44:30 +03:00
|
|
|
|
|
|
|
sort($enabledApps);
|
2013-11-25 20:34:16 +04:00
|
|
|
foreach ($enabledApps as $app) {
|
2015-04-20 17:31:43 +03:00
|
|
|
$apps['enabled'][$app] = (isset($versions[$app])) ? $versions[$app] : true;
|
2013-11-25 20:34:16 +04:00
|
|
|
}
|
2015-04-09 12:45:07 +03:00
|
|
|
|
2015-04-09 15:44:30 +03:00
|
|
|
sort($disabledApps);
|
2013-11-25 20:34:16 +04:00
|
|
|
foreach ($disabledApps as $app) {
|
2015-04-20 17:31:43 +03:00
|
|
|
$apps['disabled'][$app] = null;
|
2015-04-09 12:45:07 +03:00
|
|
|
}
|
2015-04-09 15:44:30 +03:00
|
|
|
|
|
|
|
$this->writeAppList($input, $output, $apps);
|
2015-04-09 12:45:07 +03:00
|
|
|
}
|
|
|
|
|
2015-04-09 15:44:30 +03:00
|
|
|
/**
|
|
|
|
* @param InputInterface $input
|
|
|
|
* @param OutputInterface $output
|
|
|
|
* @param array $items
|
|
|
|
*/
|
|
|
|
protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
|
|
|
|
switch ($input->getOption('output')) {
|
2015-07-17 10:25:19 +03:00
|
|
|
case self::OUTPUT_FORMAT_PLAIN:
|
2015-04-09 12:45:07 +03:00
|
|
|
$output->writeln('Enabled:');
|
|
|
|
parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
|
2015-04-09 15:44:30 +03:00
|
|
|
|
2015-04-09 12:45:07 +03:00
|
|
|
$output->writeln('Disabled:');
|
|
|
|
parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
|
|
|
|
break;
|
2015-04-09 15:44:30 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
parent::writeArrayInOutputFormat($input, $output, $items);
|
|
|
|
break;
|
2013-11-25 20:34:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|