diff options
Diffstat (limited to 'core/Command/Db/Migrations/ExecuteCommand.php')
-rw-r--r-- | core/Command/Db/Migrations/ExecuteCommand.php | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/core/Command/Db/Migrations/ExecuteCommand.php b/core/Command/Db/Migrations/ExecuteCommand.php index 88dfe648090..c3fdc128047 100644 --- a/core/Command/Db/Migrations/ExecuteCommand.php +++ b/core/Command/Db/Migrations/ExecuteCommand.php @@ -26,27 +26,35 @@ namespace OC\Core\Command\Db\Migrations; use OC\DB\MigrationService; use OC\Migration\ConsoleOutput; +use OCP\App\IAppManager; use OCP\IConfig; 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 ExecuteCommand extends Command { +class ExecuteCommand extends Command implements CompletionAwareInterface { /** @var IDBConnection */ private $connection; + /** @var IConfig */ private $config; + /** @var IAppManager */ + protected $appManager; + /** * ExecuteCommand constructor. * * @param IDBConnection $connection * @param IConfig $config + * @param IAppManager $appManager */ - public function __construct(IDBConnection $connection, IConfig $config) { + public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) { $this->connection = $connection; $this->config = $config; @@ -88,4 +96,37 @@ class ExecuteCommand extends Command { return 0; } + /** + * @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 []; + } + } |