diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-21 14:21:39 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-09-29 15:57:10 +0200 |
commit | 8906b1cc95cfb729fcedeb40402d4e8855139096 (patch) | |
tree | 3848fd5daf68d0b460e5bb036ea04f101a2292fe /core/Command/Db | |
parent | 691a5d40a4420c15a23db0f49f67a7fb1ecf7738 (diff) | |
download | nextcloud-server-8906b1cc95cfb729fcedeb40402d4e8855139096.tar.gz nextcloud-server-8906b1cc95cfb729fcedeb40402d4e8855139096.zip |
Add autocomplete for db:* and log:*
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command/Db')
-rw-r--r-- | core/Command/Db/ConvertType.php | 29 | ||||
-rw-r--r-- | core/Command/Db/GenerateChangeScript.php | 32 |
2 files changed, 59 insertions, 2 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index f8367f75867..a8969251bab 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -31,6 +31,8 @@ namespace OC\Core\Command\Db; use \OCP\IConfig; use OC\DB\Connection; use OC\DB\ConnectionFactory; +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\Helper\ProgressBar; use Symfony\Component\Console\Helper\QuestionHelper; @@ -41,7 +43,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; -class ConvertType extends Command { +class ConvertType extends Command implements CompletionAwareInterface { /** * @var \OCP\IConfig */ @@ -350,4 +352,29 @@ class ConvertType extends Command { 'dbpassword' => $password, ]); } + + /** + * Return possible values for the named option + * + * @param string $optionName + * @param CompletionContext $context + * @return string[] + */ + public function completeOptionValues($optionName, CompletionContext $context) { + return []; + } + + /** + * Return possible values for the named argument + * + * @param string $argumentName + * @param CompletionContext $context + * @return string[] + */ + public function completeArgumentValues($argumentName, CompletionContext $context) { + if ($argumentName === 'type') { + return ['mysql', 'oci', 'pgsql']; + } + return []; + } } diff --git a/core/Command/Db/GenerateChangeScript.php b/core/Command/Db/GenerateChangeScript.php index 9ef4d57967a..bbe8d29958e 100644 --- a/core/Command/Db/GenerateChangeScript.php +++ b/core/Command/Db/GenerateChangeScript.php @@ -23,12 +23,16 @@ namespace OC\Core\Command\Db; +use Stecman\Component\Symfony\Console\BashCompletion\Completion; +use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface; +use Stecman\Component\Symfony\Console\BashCompletion\Completion\ShellPathCompletion; +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 GenerateChangeScript extends Command { +class GenerateChangeScript extends Command implements CompletionAwareInterface { protected function configure() { $this ->setName('db:generate-change-script') @@ -56,4 +60,30 @@ class GenerateChangeScript extends Command { } } + + /** + * @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 === 'schema-xml') { + $helper = new ShellPathCompletion( + $this->getName(), + 'schema-xml', + Completion::TYPE_ARGUMENT + ); + return $helper->run(); + } + return []; + } } |