Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
occ app:list filter
  • Loading branch information
phil-davis committed Aug 11, 2017
commit 141f9d367e6eddd16a2d303ad96eb1af1ef5c730
27 changes: 22 additions & 5 deletions core/Command/App/ListApps.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -49,6 +50,11 @@ protected function configure() {
$this
->setName('app:list')
->setDescription('List all available apps')
->addArgument(
'search-pattern',
InputArgument::OPTIONAL,
'Restrict the list to apps whose name matches the given regular expression'
)
->addOption(
'shipped',
null,
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 12 additions & 3 deletions tests/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -167,4 +177,3 @@ fi

echo "runsh: Exit code: $RESULT"
exit $RESULT