Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-21 14:57:20 +0300
committerDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-21 14:57:20 +0300
commit63a883c6d8b5e30b9bf38a9697525ae9fd6d358a (patch)
tree86e3039306aff5ab345bba42f3f914f994fdd749 /lib/Command
parent9c052b4a066fb45644f5c50662f1d7fae0fb6e46 (diff)
Use a properly set up input definition for TRoomCommand::completeParticipantValues()
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib/Command')
-rw-r--r--lib/Command/Room/TRoomCommand.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Command/Room/TRoomCommand.php b/lib/Command/Room/TRoomCommand.php
index df598a6e2..1c6ae780b 100644
--- a/lib/Command/Room/TRoomCommand.php
+++ b/lib/Command/Room/TRoomCommand.php
@@ -35,6 +35,7 @@ use OCP\IGroup;
use OCP\IUser;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\ArgvInput;
+use Symfony\Component\Console\Input\InputDefinition;
trait TRoomCommand {
/**
@@ -327,15 +328,29 @@ trait TRoomCommand {
}
protected function completeParticipantValues(CompletionContext $context): array {
+ $definition = new InputDefinition();
+
+ if ($this->getApplication() !== null) {
+ $definition->addArguments($this->getApplication()->getDefinition()->getArguments());
+ $definition->addOptions($this->getApplication()->getDefinition()->getOptions());
+ }
+
+ $definition->addArguments($this->getDefinition()->getArguments());
+ $definition->addOptions($this->getDefinition()->getOptions());
+
+ $input = new ArgvInput($context->getWords(), $definition);
+ if ($input->hasArgument('token')) {
+ $token = $input->getArgument('token');
+ } elseif ($input->hasOption('token')) {
+ $token = $input->getOption('token');
+ } else {
+ return [];
+ }
+
/** @var Manager $roomManager */
$roomManager = \OC::$server->query(Manager::class);
- // drop `./occ talk:room:*`, but re-prepend command name for ArgvInput
- $args = array_merge([$context->getWordAtIndex(0)], array_slice($context->getWords(), 2));
- $input = new ArgvInput($args, $this->getDefinition());
-
try {
- $token = $input->getArgument('token');
$room = $roomManager->getRoomByToken($token);
} catch (RoomNotFoundException $e) {
return [];