Add cmdline key to show shipped/non-shipped apps only

This commit is contained in:
Victor Dubiniuk 2015-11-19 23:09:31 +03:00 committed by Thomas Müller
parent 2f89eef334
commit 8d9353a640
1 changed files with 17 additions and 0 deletions

View File

@ -25,6 +25,7 @@ namespace OC\Core\Command\App;
use OC\Core\Command\Base; use OC\Core\Command\Base;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class ListApps extends Base { class ListApps extends Base {
@ -34,16 +35,32 @@ class ListApps extends Base {
$this $this
->setName('app:list') ->setName('app:list')
->setDescription('List all available apps') ->setDescription('List all available apps')
->addOption(
'shipped',
null,
InputOption::VALUE_REQUIRED,
'true - limit to shipped apps only, false - limit to non-shipped apps only'
)
; ;
} }
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false'){
$shouldFilterShipped = true;
$shippedFilter = $input->getOption('shipped') === 'true';
} else {
$shouldFilterShipped = false;
}
$apps = \OC_App::getAllApps(); $apps = \OC_App::getAllApps();
$enabledApps = $disabledApps = []; $enabledApps = $disabledApps = [];
$versions = \OC_App::getAppVersions(); $versions = \OC_App::getAppVersions();
//sort enabled apps above disabled apps //sort enabled apps above disabled apps
foreach ($apps as $app) { foreach ($apps as $app) {
if ($shouldFilterShipped && \OC_App::isShipped($app) !== $shippedFilter){
continue;
}
if (\OC_App::isEnabled($app)) { if (\OC_App::isEnabled($app)) {
$enabledApps[] = $app; $enabledApps[] = $app;
} else { } else {