aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Log
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-09-21 14:21:39 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-09-29 15:57:10 +0200
commit8906b1cc95cfb729fcedeb40402d4e8855139096 (patch)
tree3848fd5daf68d0b460e5bb036ea04f101a2292fe /core/Command/Log
parent691a5d40a4420c15a23db0f49f67a7fb1ecf7738 (diff)
downloadnextcloud-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/Log')
-rw-r--r--core/Command/Log/File.php33
-rw-r--r--core/Command/Log/Manage.php33
2 files changed, 60 insertions, 6 deletions
diff --git a/core/Command/Log/File.php b/core/Command/Log/File.php
index ec490237400..d53484f086d 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 554708dfa42..578e8e8dac6 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 [];
+ }
}