diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-04-26 19:25:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 19:25:54 +0300 |
commit | 49a4008e48eeefa8fc174da8bf75020c6c91d760 (patch) | |
tree | 8a94a90af20e25f081c52e5e27937a8c386fe3ea | |
parent | ec93c59f93c13f9fd962a449f3229146c4d0e62d (diff) | |
parent | a444734fc57ed8ed0c50de567e7b1ce426ab0e32 (diff) |
Merge pull request #7223 from nextcloud/techdebt/noid/add-json-option-to-active-calls-command
Add JSON option to active-calls command
-rw-r--r-- | lib/Command/ActiveCalls.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Command/ActiveCalls.php b/lib/Command/ActiveCalls.php index a4ddf508d..48d75c15a 100644 --- a/lib/Command/ActiveCalls.php +++ b/lib/Command/ActiveCalls.php @@ -39,9 +39,11 @@ class ActiveCalls extends Base { } protected function configure(): void { + parent::configure(); + $this ->setName('talk:active-calls') - ->setDescription('Allows you to check if calls are currently in process'); + ->setDescription('Allows you to check if calls are currently in process') ; } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -56,7 +58,12 @@ class ActiveCalls extends Base { $result->closeCursor(); if ($numCalls === 0) { - $output->writeln('<info>No calls in progress</info>'); + if ($input->getOption('output') === 'plain') { + $output->writeln('<info>No calls in progress</info>'); + } else { + $data = ['calls' => 0, 'participants' => 0]; + $this->writeArrayInOutputFormat($input, $output, $data); + } return 0; } @@ -70,7 +77,13 @@ class ActiveCalls extends Base { $numParticipants = (int) $result->fetchColumn(); $result->closeCursor(); - $output->writeln(sprintf('<error>There are currently %1$d calls in progress with %2$d participants</error>', $numCalls, $numParticipants)); + + if ($input->getOption('output') === 'plain') { + $output->writeln(sprintf('<error>There are currently %1$d calls in progress with %2$d participants</error>', $numCalls, $numParticipants)); + } else { + $data = ['calls' => $numCalls, 'participants' => $numParticipants]; + $this->writeArrayInOutputFormat($input, $output, $data); + } return 1; } } |