diff options
author | Joas Schilling <coding@schilljs.com> | 2022-04-26 15:44:31 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-04-26 15:44:31 +0300 |
commit | a444734fc57ed8ed0c50de567e7b1ce426ab0e32 (patch) | |
tree | 2890ea83259088ee279d347885e7692a7cebb112 /lib | |
parent | 336cafd2190143d6c339319133249474255645ca (diff) |
Add JSON option to active-calls command
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-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; } } |