Browse Source

Fix json output

https://github.com/nextcloud/spreed/issues/8404

Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/9067/head
Vitor Mattos 3 years ago
parent
commit
bf1ca6be14
  1. 2
      lib/Command/Command/Add.php
  2. 2
      lib/Command/Command/AddSamples.php
  3. 2
      lib/Command/Command/ListCommand.php
  4. 6
      lib/Command/Command/TRenderCommand.php
  5. 2
      lib/Command/Command/Update.php

2
lib/Command/Command/Add.php

@ -110,7 +110,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>");

2
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;
}

2
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;
}
}

6
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');

2
lib/Command/Command/Update.php

@ -119,7 +119,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;
}
}
Loading…
Cancel
Save