summaryrefslogtreecommitdiffstats
path: root/core/Command/Db/Migrations/MigrateCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Db/Migrations/MigrateCommand.php')
-rw-r--r--core/Command/Db/Migrations/MigrateCommand.php37
1 files changed, 36 insertions, 1 deletions
diff --git a/core/Command/Db/Migrations/MigrateCommand.php b/core/Command/Db/Migrations/MigrateCommand.php
index e5dddaebf2d..5a4ca1a6927 100644
--- a/core/Command/Db/Migrations/MigrateCommand.php
+++ b/core/Command/Db/Migrations/MigrateCommand.php
@@ -26,12 +26,14 @@ namespace OC\Core\Command\Db\Migrations;
use OC\DB\MigrationService;
use OC\Migration\ConsoleOutput;
use OCP\IDBConnection;
+use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-class MigrateCommand extends Command {
+class MigrateCommand extends Command implements CompletionAwareInterface {
/** @var IDBConnection */
private $connection;
@@ -62,4 +64,37 @@ class MigrateCommand extends Command {
$ms->migrate($version);
}
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'app') {
+ $allApps = \OC_App::getAllApps();
+ return array_diff($allApps, \OC_App::getEnabledApps(true, true));
+ }
+
+ if ($argumentName === 'version') {
+ $appName = $context->getWordAtIndex($context->getWordIndex() - 1);
+
+ $ms = new MigrationService($appName, $this->connection);
+ $migrations = $ms->getAvailableVersions();
+
+ array_unshift($migrations, 'next', 'latest');
+ return $migrations;
+ }
+
+ return [];
+ }
+
}