Skip to content

Commit

Permalink
Fix json output
Browse files Browse the repository at this point in the history
#8404

Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-nextcloud[bot] committed May 1, 2023
1 parent e77e1bf commit db702f4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Command/Command/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$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>");
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Command/AddSamples.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

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

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$commands = $this->service->findByApp($app === 'custom' ? '' : $app);
}

$this->renderCommands($input->getOption('output'), $output, $commands, true);
$this->renderCommands($input, $output, $commands, true);
return 0;
}
}
6 changes: 4 additions & 2 deletions lib/Command/Command/TRenderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
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');
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Command/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln('<info>Command updated</info>');
$output->writeln('');
$this->renderCommands(Base::OUTPUT_FORMAT_PLAIN, $output, [$command]);
$this->renderCommands($input, $output, [$command]);
return 0;
}
}

0 comments on commit db702f4

Please sign in to comment.