diff --git a/3rdparty b/3rdparty
index f5555fef8e..cc365d1299 160000
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit f5555fef8e80d8380efb44dc8b7622a1de573c15
+Subproject commit cc365d1299570f1d0ca2e4e1eede5ead15dc9da3
diff --git a/core/Command/App/CheckCode.php b/core/Command/App/CheckCode.php
index 9c9485254d..bd1bac247a 100644
--- a/core/Command/App/CheckCode.php
+++ b/core/Command/App/CheckCode.php
@@ -29,13 +29,15 @@ use OC\App\CodeChecker\CodeChecker;
use OC\App\CodeChecker\EmptyCheck;
use OC\App\CodeChecker\InfoChecker;
use OC\App\InfoParser;
+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\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-class CheckCode extends Command {
+class CheckCode extends Command implements CompletionAwareInterface {
/** @var InfoParser */
private $infoParser;
@@ -197,4 +199,28 @@ class CheckCode extends Command {
$output->writeln("Deprecated file found: $updatePhp - please use repair steps");
}
}
+
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ if ($optionName === 'checker') {
+ return ['private', 'deprecation', 'strong-comparison'];
+ }
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'app-id') {
+ return \OC_App::getAllApps();
+ }
+ return [];
+ }
}
diff --git a/core/Command/App/Disable.php b/core/Command/App/Disable.php
index 07e752ee83..b64e309bd9 100644
--- a/core/Command/App/Disable.php
+++ b/core/Command/App/Disable.php
@@ -26,12 +26,14 @@
namespace OC\Core\Command\App;
use OCP\App\IAppManager;
+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 Disable extends Command {
+class Disable extends Command implements CompletionAwareInterface {
/** @var IAppManager */
protected $manager;
@@ -69,4 +71,25 @@ class Disable extends Command {
$output->writeln('No such app enabled: ' . $appId);
}
}
+
+ /**
+ * @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-id') {
+ return array_diff(\OC_App::getEnabledApps(true, true), $this->manager->getAlwaysEnabledApps());
+ }
+ return [];
+ }
}
diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php
index d5b161f8ea..19f24d82e4 100644
--- a/core/Command/App/Enable.php
+++ b/core/Command/App/Enable.php
@@ -26,13 +26,16 @@
namespace OC\Core\Command\App;
use OCP\App\IAppManager;
+use OCP\IGroup;
+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\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-class Enable extends Command {
+class Enable extends Command implements CompletionAwareInterface {
/** @var IAppManager */
protected $manager;
@@ -81,4 +84,31 @@ class Enable extends Command {
}
return 0;
}
+
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ if ($optionName === 'groups') {
+ return array_map(function(IGroup $group) {
+ return $group->getGID();
+ }, \OC::$server->getGroupManager()->search($context->getCurrentWord()));
+ }
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'app-id') {
+ $allApps = \OC_App::getAllApps();
+ return array_diff($allApps, \OC_App::getEnabledApps(true, true));
+ }
+ return [];
+ }
}
diff --git a/core/Command/App/GetPath.php b/core/Command/App/GetPath.php
index 3eeee5c2c4..33a812c674 100644
--- a/core/Command/App/GetPath.php
+++ b/core/Command/App/GetPath.php
@@ -23,6 +23,7 @@
namespace OC\Core\Command\App;
use OC\Core\Command\Base;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -60,4 +61,16 @@ class GetPath extends Base {
// App not found, exit with non-zero
return 1;
}
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'app') {
+ return \OC_App::getAllApps();
+ }
+ return [];
+ }
}
diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php
index 08449dd8dc..e03e3ce8f5 100644
--- a/core/Command/App/ListApps.php
+++ b/core/Command/App/ListApps.php
@@ -27,6 +27,7 @@ namespace OC\Core\Command\App;
use OC\Core\Command\Base;
use OCP\App\IAppManager;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -117,4 +118,25 @@ class ListApps extends Base {
break;
}
}
+
+ /**
+ * @param string $optionName
+ * @param CompletionContext $completionContext
+ * @return array
+ */
+ public function completeOptionValues($optionName, CompletionContext $completionContext) {
+ if ($optionName === 'shipped') {
+ return ['true', 'false'];
+ }
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ return [];
+ }
}
diff --git a/core/Command/Base.php b/core/Command/Base.php
index 5fa4468f6e..15878a807d 100644
--- a/core/Command/Base.php
+++ b/core/Command/Base.php
@@ -23,12 +23,14 @@
namespace OC\Core\Command;
+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\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-class Base extends Command {
+class Base extends Command implements CompletionAwareInterface {
const OUTPUT_FORMAT_PLAIN = 'plain';
const OUTPUT_FORMAT_JSON = 'json';
const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty';
@@ -158,4 +160,25 @@ class Base extends Command {
return parent::run($input, $output);
}
+
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ if ($optionName === 'output') {
+ return ['plain', 'json', 'json_pretty'];
+ }
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ return [];
+ }
}
diff --git a/core/Command/Config/App/Base.php b/core/Command/Config/App/Base.php
new file mode 100644
index 0000000000..3f29591dd1
--- /dev/null
+++ b/core/Command/Config/App/Base.php
@@ -0,0 +1,48 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OC\Core\Command\Config\App;
+
+use OCP\IConfig;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
+
+abstract class Base extends \OC\Core\Command\Base {
+
+ /** * @var IConfig */
+ protected $config;
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'app') {
+ return \OC_App::getAllApps();
+ }
+
+ if ($argumentName === 'name') {
+ $appName = $context->getWordAtIndex($context->getWordIndex() - 1);
+ return $this->config->getAppKeys($appName);
+ }
+ return [];
+ }
+}
diff --git a/core/Command/Config/App/DeleteConfig.php b/core/Command/Config/App/DeleteConfig.php
index 82099556ca..9cb28c9774 100644
--- a/core/Command/Config/App/DeleteConfig.php
+++ b/core/Command/Config/App/DeleteConfig.php
@@ -22,7 +22,6 @@
namespace OC\Core\Command\Config\App;
-use OC\Core\Command\Base;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/core/Command/Config/App/GetConfig.php b/core/Command/Config/App/GetConfig.php
index eb81b1b19b..fe365c2546 100644
--- a/core/Command/Config/App/GetConfig.php
+++ b/core/Command/Config/App/GetConfig.php
@@ -22,7 +22,6 @@
namespace OC\Core\Command\Config\App;
-use OC\Core\Command\Base;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/core/Command/Config/App/SetConfig.php b/core/Command/Config/App/SetConfig.php
index aa84ddf1d8..e7f5c8ac61 100644
--- a/core/Command/Config/App/SetConfig.php
+++ b/core/Command/Config/App/SetConfig.php
@@ -22,7 +22,6 @@
namespace OC\Core\Command\Config\App;
-use OC\Core\Command\Base;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/core/Command/Config/Import.php b/core/Command/Config/Import.php
index a27d1b62f0..4a8db1c965 100644
--- a/core/Command/Config/Import.php
+++ b/core/Command/Config/Import.php
@@ -23,12 +23,16 @@
namespace OC\Core\Command\Config;
use OCP\IConfig;
+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 Import extends Command {
+class Import extends Command implements CompletionAwareInterface {
protected $validRootKeys = ['system', 'apps'];
/** @var IConfig */
@@ -193,4 +197,30 @@ class Import 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 === 'file') {
+ $helper = new ShellPathCompletion(
+ $this->getName(),
+ 'file',
+ Completion::TYPE_ARGUMENT
+ );
+ return $helper->run();
+ }
+ return [];
+ }
}
diff --git a/core/Command/Config/ListConfigs.php b/core/Command/Config/ListConfigs.php
index e11eec1a7a..2737bc2cea 100644
--- a/core/Command/Config/ListConfigs.php
+++ b/core/Command/Config/ListConfigs.php
@@ -25,6 +25,7 @@ namespace OC\Core\Command\Config;
use OC\Core\Command\Base;
use OC\SystemConfig;
use OCP\IAppConfig;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -127,4 +128,16 @@ class ListConfigs extends Base {
return $configs;
}
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'app') {
+ return array_merge(['all', 'system'], \OC_App::getAllApps());
+ }
+ return [];
+ }
}
diff --git a/core/Command/Config/System/Base.php b/core/Command/Config/System/Base.php
new file mode 100644
index 0000000000..4e49baf5ab
--- /dev/null
+++ b/core/Command/Config/System/Base.php
@@ -0,0 +1,78 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OC\Core\Command\Config\System;
+
+use OC\SystemConfig;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
+
+abstract class Base extends \OC\Core\Command\Base {
+
+ /** @var SystemConfig */
+ protected $systemConfig;
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ if ($argumentName === 'name') {
+ $words = $this->getPreviousNames($context, $context->getWordIndex());
+ if (empty($words)) {
+ $completions = $this->systemConfig->getKeys();
+ } else {
+ $key = array_shift($words);
+ $value = $this->systemConfig->getValue($key);
+ $completions = array_keys($value);
+
+ while (!empty($words) && is_array($value)) {
+ $key = array_shift($words);
+ if (!isset($value[$key]) || !is_array($value[$key])) {
+ break;
+ }
+
+ $value = $value[$key];
+ $completions = array_keys($value);
+ }
+ }
+
+ return $completions;
+ }
+ return parent::completeArgumentValues($argumentName, $context);
+ }
+
+ /**
+ * @param CompletionContext $context
+ * @param int $currentIndex
+ * @return string[]
+ */
+ protected function getPreviousNames(CompletionContext $context, $currentIndex) {
+ $word = $context->getWordAtIndex($currentIndex - 1);
+ if ($word === $this->getName() || $currentIndex <= 0) {
+ return [];
+ }
+
+ $words = $this->getPreviousNames($context, $currentIndex - 1);
+ $words[] = $word;
+ return $words;
+ }
+}
diff --git a/core/Command/Config/System/DeleteConfig.php b/core/Command/Config/System/DeleteConfig.php
index 65f26f7b2a..216cf4eb64 100644
--- a/core/Command/Config/System/DeleteConfig.php
+++ b/core/Command/Config/System/DeleteConfig.php
@@ -22,7 +22,6 @@
namespace OC\Core\Command\Config\System;
-use OC\Core\Command\Base;
use OC\SystemConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/core/Command/Config/System/GetConfig.php b/core/Command/Config/System/GetConfig.php
index 7c2f663e42..11ead7456c 100644
--- a/core/Command/Config/System/GetConfig.php
+++ b/core/Command/Config/System/GetConfig.php
@@ -22,7 +22,6 @@
namespace OC\Core\Command\Config\System;
-use OC\Core\Command\Base;
use OC\SystemConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/core/Command/Config/System/SetConfig.php b/core/Command/Config/System/SetConfig.php
index fcbf3c0baa..992fca8d08 100644
--- a/core/Command/Config/System/SetConfig.php
+++ b/core/Command/Config/System/SetConfig.php
@@ -23,8 +23,8 @@
namespace OC\Core\Command\Config\System;
-use OC\Core\Command\Base;
use OC\SystemConfig;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -196,4 +196,15 @@ class SetConfig extends Base {
return $existingValues;
}
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ if ($optionName === 'type') {
+ return ['string', 'integer', 'double', 'boolean'];
+ }
+ return parent::completeOptionValues($optionName, $context);
+ }
}
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php
index f8367f7586..a8969251ba 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 9ef4d57967..bbe8d29958 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 [];
+ }
}
diff --git a/core/Command/L10n/CreateJs.php b/core/Command/L10n/CreateJs.php
index 53e897e6b4..e52f588b83 100644
--- a/core/Command/L10n/CreateJs.php
+++ b/core/Command/L10n/CreateJs.php
@@ -25,13 +25,15 @@ namespace OC\Core\Command\L10n;
use DirectoryIterator;
+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\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use UnexpectedValueException;
-class CreateJs extends Command {
+class CreateJs extends Command implements CompletionAwareInterface {
protected function configure() {
$this
@@ -135,4 +137,32 @@ class CreateJs extends Command {
return array($TRANSLATIONS, $PLURAL_FORMS);
}
+
+ /**
+ * 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 === 'app') {
+ return \OC_App::getAllApps();
+ } else if ($argumentName === 'lang') {
+ $appName = $context->getWordAtIndex($context->getWordIndex() - 1);
+ return $this->getAllLanguages(\OC_App::getAppPath($appName));
+ }
+ return [];
+ }
}
diff --git a/core/Command/Log/File.php b/core/Command/Log/File.php
index ec49023740..d53484f086 100644
--- a/core/Command/Log/File.php
+++ b/core/Command/Log/File.php
@@ -25,13 +25,15 @@ namespace OC\Core\Command\Log;
use \OCP\IConfig;
+use Stecman\Component\Symfony\Console\BashCompletion\Completion;
+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\InputInterface;
-use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-class File extends Command {
+class File extends Command implements Completion\CompletionAwareInterface {
/** @var IConfig */
protected $config;
@@ -125,4 +127,31 @@ class File extends Command {
}
}
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ if ($optionName === 'file') {
+ $helper = new ShellPathCompletion(
+ $this->getName(),
+ 'file',
+ Completion::TYPE_OPTION
+ );
+ return $helper->run();
+ } else if ($optionName === 'rotate-size') {
+ return [0];
+ }
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ return [];
+ }
}
diff --git a/core/Command/Log/Manage.php b/core/Command/Log/Manage.php
index 554708dfa4..578e8e8dac 100644
--- a/core/Command/Log/Manage.php
+++ b/core/Command/Log/Manage.php
@@ -24,15 +24,15 @@
namespace OC\Core\Command\Log;
-use \OCP\IConfig;
-
+use OCP\IConfig;
+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\InputInterface;
-use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-class Manage extends Command {
+class Manage extends Command implements CompletionAwareInterface {
const DEFAULT_BACKEND = 'file';
const DEFAULT_LOG_LEVEL = 2;
@@ -172,4 +172,29 @@ class Manage extends Command {
}
throw new \InvalidArgumentException('Invalid log level number');
}
+
+ /**
+ * @param string $optionName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeOptionValues($optionName, CompletionContext $context) {
+ if ($optionName === 'backend') {
+ return ['file', 'syslog', 'errorlog'];
+ } else if ($optionName === 'level') {
+ return ['debug', 'info', 'warning', 'error'];
+ } else if ($optionName === 'timezone') {
+ return \DateTimeZone::listIdentifiers();
+ }
+ return [];
+ }
+
+ /**
+ * @param string $argumentName
+ * @param CompletionContext $context
+ * @return string[]
+ */
+ public function completeArgumentValues($argumentName, CompletionContext $context) {
+ return [];
+ }
}
diff --git a/core/Command/TwoFactorAuth/Base.php b/core/Command/TwoFactorAuth/Base.php
new file mode 100644
index 0000000000..e99703ecd7
--- /dev/null
+++ b/core/Command/TwoFactorAuth/Base.php
@@ -0,0 +1,60 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OC\Core\Command\TwoFactorAuth;
+
+use OCP\IUserManager;
+use OCP\IUser;
+use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
+use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
+
+class Base extends \OC\Core\Command\Base implements CompletionAwareInterface {
+
+ /** @var IUserManager */
+ protected $userManager;
+
+ /**
+ * 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 === 'uid') {
+ return array_map(function(IUser $user) {
+ return $user->getUID();
+ }, $this->userManager->search($context->getCurrentWord(), 100));
+ }
+ return [];
+ }
+}
diff --git a/core/Command/TwoFactorAuth/Disable.php b/core/Command/TwoFactorAuth/Disable.php
index 60e1bf7181..d0303edac3 100644
--- a/core/Command/TwoFactorAuth/Disable.php
+++ b/core/Command/TwoFactorAuth/Disable.php
@@ -23,8 +23,7 @@
namespace OC\Core\Command\TwoFactorAuth;
use OC\Authentication\TwoFactorAuth\Manager;
-use OC\User\Manager as UserManager;
-use OC\Core\Command\Base;
+use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -34,10 +33,10 @@ class Disable extends Base {
/** @var Manager */
private $manager;
- /** @var UserManager */
- private $userManager;
+ /** @var IUserManager */
+ protected $userManager;
- public function __construct(Manager $manager, UserManager $userManager) {
+ public function __construct(Manager $manager, IUserManager $userManager) {
parent::__construct('twofactorauth:disable');
$this->manager = $manager;
$this->userManager = $userManager;
diff --git a/core/Command/TwoFactorAuth/Enable.php b/core/Command/TwoFactorAuth/Enable.php
index 54fc6cdf06..a15fb83b66 100644
--- a/core/Command/TwoFactorAuth/Enable.php
+++ b/core/Command/TwoFactorAuth/Enable.php
@@ -23,8 +23,7 @@
namespace OC\Core\Command\TwoFactorAuth;
use OC\Authentication\TwoFactorAuth\Manager;
-use OC\User\Manager as UserManager;
-use OC\Core\Command\Base;
+use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -34,10 +33,10 @@ class Enable extends Base {
/** @var Manager */
private $manager;
- /** @var UserManager */
- private $userManager;
+ /** @var IUserManager */
+ protected $userManager;
- public function __construct(Manager $manager, UserManager $userManager) {
+ public function __construct(Manager $manager, IUserManager $userManager) {
parent::__construct('twofactorauth:enable');
$this->manager = $manager;
$this->userManager = $userManager;
diff --git a/core/register_command.php b/core/register_command.php
index 6a220c22b3..23621e54f8 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -33,6 +33,7 @@
*/
/** @var $application Symfony\Component\Console\Application */
+$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
$application->add(new OC\Core\Command\Status);
$application->add(new OC\Core\Command\Check(\OC::$server->getConfig()));
$infoParser = new \OC\App\InfoParser(\OC::$server->getURLGenerator());
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 1d18674f65..75929bdbef 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -337,11 +337,13 @@ return array(
'OC\\Core\\Command\\Background\\WebCron' => $baseDir . '/core/Command/Background/WebCron.php',
'OC\\Core\\Command\\Base' => $baseDir . '/core/Command/Base.php',
'OC\\Core\\Command\\Check' => $baseDir . '/core/Command/Check.php',
+ 'OC\\Core\\Command\\Config\\App\\Base' => $baseDir . '/core/Command/Config/App/Base.php',
'OC\\Core\\Command\\Config\\App\\DeleteConfig' => $baseDir . '/core/Command/Config/App/DeleteConfig.php',
'OC\\Core\\Command\\Config\\App\\GetConfig' => $baseDir . '/core/Command/Config/App/GetConfig.php',
'OC\\Core\\Command\\Config\\App\\SetConfig' => $baseDir . '/core/Command/Config/App/SetConfig.php',
'OC\\Core\\Command\\Config\\Import' => $baseDir . '/core/Command/Config/Import.php',
'OC\\Core\\Command\\Config\\ListConfigs' => $baseDir . '/core/Command/Config/ListConfigs.php',
+ 'OC\\Core\\Command\\Config\\System\\Base' => $baseDir . '/core/Command/Config/System/Base.php',
'OC\\Core\\Command\\Config\\System\\DeleteConfig' => $baseDir . '/core/Command/Config/System/DeleteConfig.php',
'OC\\Core\\Command\\Config\\System\\GetConfig' => $baseDir . '/core/Command/Config/System/GetConfig.php',
'OC\\Core\\Command\\Config\\System\\SetConfig' => $baseDir . '/core/Command/Config/System/SetConfig.php',
@@ -378,6 +380,7 @@ return array(
'OC\\Core\\Command\\Security\\ListCertificates' => $baseDir . '/core/Command/Security/ListCertificates.php',
'OC\\Core\\Command\\Security\\RemoveCertificate' => $baseDir . '/core/Command/Security/RemoveCertificate.php',
'OC\\Core\\Command\\Status' => $baseDir . '/core/Command/Status.php',
+ 'OC\\Core\\Command\\TwoFactorAuth\\Base' => $baseDir . '/core/Command/TwoFactorAuth/Base.php',
'OC\\Core\\Command\\TwoFactorAuth\\Disable' => $baseDir . '/core/Command/TwoFactorAuth/Disable.php',
'OC\\Core\\Command\\TwoFactorAuth\\Enable' => $baseDir . '/core/Command/TwoFactorAuth/Enable.php',
'OC\\Core\\Command\\Upgrade' => $baseDir . '/core/Command/Upgrade.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 1051bca2f7..e07e07edc4 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -367,11 +367,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Core\\Command\\Background\\WebCron' => __DIR__ . '/../../..' . '/core/Command/Background/WebCron.php',
'OC\\Core\\Command\\Base' => __DIR__ . '/../../..' . '/core/Command/Base.php',
'OC\\Core\\Command\\Check' => __DIR__ . '/../../..' . '/core/Command/Check.php',
+ 'OC\\Core\\Command\\Config\\App\\Base' => __DIR__ . '/../../..' . '/core/Command/Config/App/Base.php',
'OC\\Core\\Command\\Config\\App\\DeleteConfig' => __DIR__ . '/../../..' . '/core/Command/Config/App/DeleteConfig.php',
'OC\\Core\\Command\\Config\\App\\GetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/App/GetConfig.php',
'OC\\Core\\Command\\Config\\App\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/App/SetConfig.php',
'OC\\Core\\Command\\Config\\Import' => __DIR__ . '/../../..' . '/core/Command/Config/Import.php',
'OC\\Core\\Command\\Config\\ListConfigs' => __DIR__ . '/../../..' . '/core/Command/Config/ListConfigs.php',
+ 'OC\\Core\\Command\\Config\\System\\Base' => __DIR__ . '/../../..' . '/core/Command/Config/System/Base.php',
'OC\\Core\\Command\\Config\\System\\DeleteConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/DeleteConfig.php',
'OC\\Core\\Command\\Config\\System\\GetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/GetConfig.php',
'OC\\Core\\Command\\Config\\System\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/SetConfig.php',
@@ -408,6 +410,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Core\\Command\\Security\\ListCertificates' => __DIR__ . '/../../..' . '/core/Command/Security/ListCertificates.php',
'OC\\Core\\Command\\Security\\RemoveCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/RemoveCertificate.php',
'OC\\Core\\Command\\Status' => __DIR__ . '/../../..' . '/core/Command/Status.php',
+ 'OC\\Core\\Command\\TwoFactorAuth\\Base' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Base.php',
'OC\\Core\\Command\\TwoFactorAuth\\Disable' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Disable.php',
'OC\\Core\\Command\\TwoFactorAuth\\Enable' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Enable.php',
'OC\\Core\\Command\\Upgrade' => __DIR__ . '/../../..' . '/core/Command/Upgrade.php',
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php
index cad16a070c..3033d7beb8 100644
--- a/lib/private/Console/Application.php
+++ b/lib/private/Console/Application.php
@@ -88,10 +88,14 @@ class Application {
require_once __DIR__ . '/../../../core/register_command.php';
if ($this->config->getSystemValue('installed', false)) {
if (\OCP\Util::needUpgrade()) {
- $output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
- $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
+ if ($input->getArgument('command') !== '_completion') {
+ $output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
+ $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
+ }
} elseif ($this->config->getSystemValue('maintenance', false)) {
- $output->writeln("Nextcloud is in maintenance mode - no app have been loaded");
+ if ($input->getArgument('command') !== '_completion') {
+ $output->writeln("Nextcloud is in maintenance mode - no apps have been loaded");
+ }
} else {
OC_App::loadApps();
foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
@@ -106,10 +110,10 @@ class Application {
}
}
}
- } else {
+ } else if ($input->getArgument('command') !== '_completion') {
$output->writeln("Nextcloud is not installed - only a limited number of commands are available");
}
- $input = new ArgvInput();
+
if ($input->getFirstArgument() !== 'check') {
$errors = \OC_Util::checkServer(\OC::$server->getConfig());
if (!empty($errors)) {