summaryrefslogtreecommitdiffstats
path: root/core/Command/Db/Migrations/GenerateCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Db/Migrations/GenerateCommand.php')
-rw-r--r--core/Command/Db/Migrations/GenerateCommand.php42
1 files changed, 40 insertions, 2 deletions
diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php
index e37c51e85fb..50d58a9ea16 100644
--- a/core/Command/Db/Migrations/GenerateCommand.php
+++ b/core/Command/Db/Migrations/GenerateCommand.php
@@ -26,14 +26,17 @@ namespace OC\Core\Command\Db\Migrations;
use OC\DB\MigrationService;
use OC\Migration\ConsoleOutput;
+use OCP\App\IAppManager;
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\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-class GenerateCommand extends Command {
+class GenerateCommand extends Command implements CompletionAwareInterface {
protected static $_templateSimple =
'<?php
@@ -82,11 +85,16 @@ class {{classname}} extends SimpleMigrationStep {
/** @var IDBConnection */
protected $connection;
+ /** @var IAppManager */
+ protected $appManager;
+
/**
* @param IDBConnection $connection
+ * @param IAppManager $appManager
*/
- public function __construct(IDBConnection $connection) {
+ public function __construct(IDBConnection $connection, IAppManager $appManager) {
$this->connection = $connection;
+ $this->appManager = $appManager;
parent::__construct();
}
@@ -120,6 +128,36 @@ class {{classname}} extends SimpleMigrationStep {
}
/**
+ * @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);
+
+ $version = explode('.', $this->appManager->getAppVersion($appName));
+ return [$version[0] . sprintf('%1$03d', $version[1])];
+ }
+
+ return [];
+ }
+
+ /**
* @param MigrationService $ms
* @param string $className
* @param string $schemaBody