diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php index ff9777bddb56..0d0c19afd283 100644 --- a/core/Command/App/ListApps.php +++ b/core/Command/App/ListApps.php @@ -27,6 +27,7 @@ use OC\Core\Command\Base; use OCP\App\IAppManager; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -49,6 +50,11 @@ protected function configure() { $this ->setName('app:list') ->setDescription('List all available apps') + ->addArgument( + 'search-pattern', + InputArgument::OPTIONAL, + 'Restrict the list of apps to those whose name matches the given regular expression' + ) ->addOption( 'shipped', null, @@ -59,6 +65,8 @@ protected function configure() { } protected function execute(InputInterface $input, OutputInterface $output) { + $appNameSubString = $input->getArgument('search-pattern'); + if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false'){ $shippedFilter = $input->getOption('shipped') === 'true'; } else { @@ -74,6 +82,11 @@ protected function execute(InputInterface $input, OutputInterface $output) { if ($shippedFilter !== null && \OC_App::isShipped($app) !== $shippedFilter){ continue; } + + if ($appNameSubString !== null && !preg_match('/' . $appNameSubString . '/', $app)) { + continue; + } + if ($this->manager->isInstalled($app)) { $enabledApps[] = $app; } else { @@ -104,11 +117,15 @@ protected function execute(InputInterface $input, OutputInterface $output) { protected function writeAppList(InputInterface $input, OutputInterface $output, $items) { switch ($input->getOption('output')) { case self::OUTPUT_FORMAT_PLAIN: - $output->writeln('Enabled:'); - parent::writeArrayInOutputFormat($input, $output, $items['enabled']); - - $output->writeln('Disabled:'); - parent::writeArrayInOutputFormat($input, $output, $items['disabled']); + if (count($items['enabled'])) { + $output->writeln('Enabled:'); + parent::writeArrayInOutputFormat($input, $output, $items['enabled']); + } + + if (count($items['disabled'])) { + $output->writeln('Disabled:'); + parent::writeArrayInOutputFormat($input, $output, $items['disabled']); + } break; default: diff --git a/tests/integration/run.sh b/tests/integration/run.sh index a88f09ac7028..81d817d5f2a5 100755 --- a/tests/integration/run.sh +++ b/tests/integration/run.sh @@ -80,7 +80,14 @@ $OCC config:system:set skeletondirectory --value="$(pwd)/skeleton" $OCC config:app:set core enable_external_storage --value=yes $OCC config:system:set files_external_allow_create_new_local --value=true -$OCC app:enable testing +PREVIOUS_TESTING_APP_STATUS=$($OCC app:list "^testing$") +if [[ "$PREVIOUS_TESTING_APP_STATUS" =~ ^Disabled: ]] +then + $OCC app:enable testing + TESTING_ENABLED_BY_SCRIPT=true; +else + TESTING_ENABLED_BY_SCRIPT=false; +fi mkdir -p work/local_storage || { echo "Unable to create work folder" >&2; exit 1; } OUTPUT_CREATE_STORAGE=`$OCC files_external:create local_storage local null::null -c datadir=$SCRIPT_PATH/work/local_storage` @@ -132,7 +139,10 @@ $OCC files_external:delete -y $ID_STORAGE #Disable external storage app $OCC config:app:set core enable_external_storage --value=no -$OCC app:disable testing +# Put back state of the testing app +if test "$TESTING_ENABLED_BY_SCRIPT" = true; then + $OCC app:disable testing +fi # Put back personalized skeleton if test "A$PREVIOUS_SKELETON_DIR" = "A"; then @@ -167,4 +177,3 @@ fi echo "runsh: Exit code: $RESULT" exit $RESULT -