summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-05-01 15:34:58 +0200
committerGitHub <noreply@github.com>2023-05-01 15:34:58 +0200
commit8455abbb3397650911de0f53c106a2a851980145 (patch)
tree16831590e0b338a6c3dd45972684e00eaf1206aa /lib
parent9ee3bc42c01c5aa80e12319e8e9db86f64cbafa0 (diff)
parent5e52a9dd41c906c54a8bb6c1333184ccbe307677 (diff)
Merge pull request #9067 from nextcloud/bugfix/8404/fix-json-output
Fix json output
Diffstat (limited to 'lib')
-rw-r--r--lib/Command/Command/Add.php3
-rw-r--r--lib/Command/Command/AddSamples.php2
-rw-r--r--lib/Command/Command/ListCommand.php2
-rw-r--r--lib/Command/Command/TRenderCommand.php6
-rw-r--r--lib/Command/Command/Update.php3
5 files changed, 10 insertions, 6 deletions
diff --git a/lib/Command/Command/Add.php b/lib/Command/Command/Add.php
index 17e473d7b..2cc51a8ab 100644
--- a/lib/Command/Command/Add.php
+++ b/lib/Command/Command/Add.php
@@ -40,6 +40,7 @@ class Add extends Base {
}
protected function configure(): void {
+ parent::configure();
$this
->setName('talk:command:add')
->setDescription('Add a new command')
@@ -110,7 +111,7 @@ class Add extends Base {
$output->writeln('<info>Command added</info>');
$output->writeln('');
- $this->renderCommands(Base::OUTPUT_FORMAT_PLAIN, $output, [$command]);
+ $this->renderCommands($input, $output, [$command]);
$output->writeln('');
$output->writeln("<comment>If you think your command makes sense for other users as well, feel free to share it in the following github issue:\n https://github.com/nextcloud/spreed/issues/1566</comment>");
diff --git a/lib/Command/Command/AddSamples.php b/lib/Command/Command/AddSamples.php
index f7aec9449..561e74b7e 100644
--- a/lib/Command/Command/AddSamples.php
+++ b/lib/Command/Command/AddSamples.php
@@ -107,7 +107,7 @@ class AddSamples extends Base {
$output->writeln('<info>Commands added</info>');
$output->writeln('');
- $this->renderCommands(Base::OUTPUT_FORMAT_PLAIN, $output, $this->commands);
+ $this->renderCommands($input, $output, $this->commands);
return 0;
}
diff --git a/lib/Command/Command/ListCommand.php b/lib/Command/Command/ListCommand.php
index 01d9f2afb..9ef03f7c0 100644
--- a/lib/Command/Command/ListCommand.php
+++ b/lib/Command/Command/ListCommand.php
@@ -57,7 +57,7 @@ class ListCommand extends Base {
$commands = $this->service->findByApp($app === 'custom' ? '' : $app);
}
- $this->renderCommands($input->getOption('output'), $output, $commands, true);
+ $this->renderCommands($input, $output, $commands, true);
return 0;
}
}
diff --git a/lib/Command/Command/TRenderCommand.php b/lib/Command/Command/TRenderCommand.php
index ffa05396e..345fe1ba1 100644
--- a/lib/Command/Command/TRenderCommand.php
+++ b/lib/Command/Command/TRenderCommand.php
@@ -26,15 +26,17 @@ namespace OCA\Talk\Command\Command;
use OC\Core\Command\Base;
use OCA\Talk\Model\Command;
use Symfony\Component\Console\Helper\Table;
+use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
trait TRenderCommand {
- protected function renderCommands(string $outputFormat, OutputInterface $output, array $commands, bool $showHelp = false): void {
+ protected function renderCommands(InputInterface $input, OutputInterface $output, array $commands, bool $showHelp = false): void {
$result = array_map(function (Command $command) {
return $command->asArray();
}, $commands);
- if ($outputFormat === Base::OUTPUT_FORMAT_PLAIN) {
+ $plainText = $input->getOption('output') ?? Base::OUTPUT_FORMAT_PLAIN;
+ if ($plainText === Base::OUTPUT_FORMAT_PLAIN) {
if ($showHelp) {
$output->writeln('Response values: 0 - No one, 1 - User, 2 - All');
$output->writeln('Enabled values: 0 - Disabled, 1 - Moderators, 2 - Users, 3 - Guests');
diff --git a/lib/Command/Command/Update.php b/lib/Command/Command/Update.php
index 9d7c16fa0..7f2b22746 100644
--- a/lib/Command/Command/Update.php
+++ b/lib/Command/Command/Update.php
@@ -41,6 +41,7 @@ class Update extends Base {
}
protected function configure(): void {
+ parent::configure();
$this
->setName('talk:command:update')
->setDescription('Add a new command')
@@ -119,7 +120,7 @@ class Update extends Base {
$output->writeln('<info>Command updated</info>');
$output->writeln('');
- $this->renderCommands(Base::OUTPUT_FORMAT_PLAIN, $output, [$command]);
+ $this->renderCommands($input, $output, [$command]);
return 0;
}
}